Testing CouchDB sync.
This commit is contained in:
parent
30a7bdfd12
commit
55164ef2a3
|
@ -373,16 +373,17 @@ export const getGpx = async (params: any) => {
|
||||||
gpx = row.doc.doc;
|
gpx = row.doc.doc;
|
||||||
}
|
}
|
||||||
//level 1 (extensions)
|
//level 1 (extensions)
|
||||||
if (row.doc.type === 'extensions') {
|
if (target !== undefined && row.doc.type === 'extensions') {
|
||||||
target.splice(1);
|
target.splice(1);
|
||||||
appendToArray(target.at(-1), row.doc.type, row.doc.doc);
|
appendToArray(target.at(-1), row.doc.type, row.doc.doc);
|
||||||
target.push(row.doc.doc);
|
target.push(row.doc.doc);
|
||||||
}
|
}
|
||||||
//level 1 (others)
|
//level 1 (others)
|
||||||
if (
|
if (
|
||||||
row.doc.type === 'wpt' ||
|
target !== undefined &&
|
||||||
|
(row.doc.type === 'wpt' ||
|
||||||
row.doc.type === 'rte' ||
|
row.doc.type === 'rte' ||
|
||||||
row.doc.type === 'trk'
|
row.doc.type === 'trk')
|
||||||
) {
|
) {
|
||||||
target.splice(1);
|
target.splice(1);
|
||||||
appendToArray(target.at(-1), row.doc.type, row.doc._id);
|
appendToArray(target.at(-1), row.doc.type, row.doc._id);
|
||||||
|
|
|
@ -51,6 +51,39 @@ export const initDb = async (params: any) => {
|
||||||
|
|
||||||
globalThis.dbReady = true;
|
globalThis.dbReady = true;
|
||||||
|
|
||||||
|
const sync = PouchDB.sync(
|
||||||
|
'dyomedea',
|
||||||
|
'http://admin:password@localhost:5984/dyomedea',
|
||||||
|
{
|
||||||
|
live: true,
|
||||||
|
retry: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.on('change', function (info) {
|
||||||
|
// handle change
|
||||||
|
console.log({ caller: 'Sync / change', info });
|
||||||
|
})
|
||||||
|
.on('paused', function (err) {
|
||||||
|
// replication paused (e.g. replication up to date, user went offline)
|
||||||
|
console.log({ caller: 'Sync / paused', err });
|
||||||
|
})
|
||||||
|
.on('active', function () {
|
||||||
|
// replicate resumed (e.g. new changes replicating, user went back online)
|
||||||
|
console.log({ caller: 'Sync / active' });
|
||||||
|
})
|
||||||
|
.on('denied', function (err) {
|
||||||
|
// a document failed to replicate (e.g. due to permissions)
|
||||||
|
console.error({ caller: 'Sync / denied', err });
|
||||||
|
})
|
||||||
|
.on('complete', function (info) {
|
||||||
|
// handle complete
|
||||||
|
console.log({ caller: 'Sync / complete', info });
|
||||||
|
})
|
||||||
|
.on('error', function (err) {
|
||||||
|
// handle error
|
||||||
|
console.error({ caller: 'Sync / error', err });
|
||||||
|
});
|
||||||
|
|
||||||
console.log({ caller: 'initDb / before db.changes' });
|
console.log({ caller: 'initDb / before db.changes' });
|
||||||
|
|
||||||
const changes = db
|
const changes = db
|
||||||
|
|
Loading…
Reference in New Issue