Git Product home page Git Product logo

pouchdb-load's People

Contributors

bmihelac avatar coniglioz avatar jkleinsc avatar nolanlawson avatar robertkeizer avatar wegewerk-mdt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pouchdb-load's Issues

Error loading dump with filter view

The error is:
TypeError: Cannot read property 'toString' of undefined at generateReplicationId
on line 2272 of pouchdb.load.js

This happens when you load the dump using a view as filter, for example:

db.load('http://example.com/my-dump-file.txt', {
  proxy: 'http://mysite.com/mydb',
  filter: '_view',
  view: 'mydesign/myview'
})

Suggested solution
Complete the "replIdOpts" object passed to "genReplicationId" on line 67 by adding the "view" attribute.

...
if (opts.view) {
  replIdOpts.view = opts.view;
}
...

running PouchDB.load, TypeError: object is not a function TypeError: object is not a function at PouchDB

this.local = new PouchDB(this.dbName, {auto_compaction: true, adapter: 'websql'});
This error occurs while running this code, "
this.local.load('couchdb/calibers.txt' , {
proxy: this.remote.name,
ajax: {
cache: true
}})
.then((result) => {
console.log(result);
})
.catch((err)=>{
console.log(err);
})"

im using this pouchdb versions.
"pouchdb": "~6.3.4",
"pouchdb-adapter-memory": "^6.2.0",
"pouchdb-adapter-websql-core": "6.2.0",
"pouchdb-browser": "6.2.0",
"pouchdb-find": "^6.3.4",
"pouchdb-load": "^1.4.6",
"pouchdb-upsert": "^2.2.0",

any solution for this?

how to load json file in pouchdb

hi,

i have a json file and i want to load these data in my pouchDB in ionic 2. this is my code:

      let PouchDB = require('pouchdb');
      PouchDB.plugin(require('pouchdb-load'));
      initDB() {
      this._db = new PouchDB('product4', { adapter: 'websql' });
       var myDumpedString = [{
        "name": "Product",
        "properties":
        {
            "id":
            {
                "type": "number",
                "description": "Product identifier",
                "required": true
            },
            "name":
            {
                "description": "Name of the product",
                "type": "string",
                "required": true
            },
            "price":
            {
                "type": "number",
                "minimum": 0,
                "required": true
            },
            "tags":
            {
                "type": "array",
                "items":
                {
                    "type": "string"
                }
            }
        }
    }];
    console.log((JSON.stringify(myDumpedString))); 
    this._db.load(myDumpedString).then(function () {
        console.log("Done loading!");
    }).catch(function (err) {
        console.log("error!");
    });

    window["PouchDB"] = PouchDB;
}

when i run this code, i see the json data in console but after that i will get this error:

     GET http://localhost:8100/[object%20Object] 404 (Not Found)
     error!

any help? is this way correct? or i should use another way?
Thanks

unable to load data with proxy on react native app

I am trying to load data on my React native app it is working fine when I try to load data without a proxy. But when adding proxy it does not giving any error and also not load any data it is stuck for an unlimited time

    array.forEach(function (dumpFile) {
          series = series.then(function () {
           
            return localdb.load(dumpFile, {
              proxy: "https://v2.abc.xyz/abc",
              auth: {
                username: "admin",
                password: "****",
              },
            })
          });
        });

    I am using  `react-native-sqlite` adapter

const localdb = new PouchDB("siloc", {
 adapter: "react-native-sqlite",
});

Auth headers not set on requests if proxy is set.

  db.info().then(function (info) {
    var src = new db.constructor(opts.proxy, opts);
    var target = new db.constructor(info.db_name, opts);
    var replIdOpts = {};
    if (opts.filter) {
      replIdOpts.filter = opts.filter;
    }

The following code changes seem to work.

Subsequent continuous replication fails if load source DB is different from continuous replication DB

Our architecture is as follows:

  • Client (local replica)
  • Database A (master, load source)
  • Database B (continuous replication source)

Order of events:

  1. Our client does a load from Database A via a pouchdb-replication-stream dump, setting "proxy" to Database B's URL.
  2. When load is done, the client initiates a continuous replication from Database B.

Unfortunately, we're not seeing any changes from the subsequent continuous replication.
This is regardless of whether the change originates from database A (via B), or database B directly.

We're seeing _changes documents being retrieved (which include the changed documents), but those changes aren't applied to the local replica.

Our code looks something like this:

  var startSync = function () {
    console.log('enabling DB sync');

    var replicationFilter = function (doc) {
      return (doc['document-type'] && doc['document-type'] !== "attachment") || (doc._deleted);
    };

    var startRegularReplication = function () {
      // Initial status
      service.status = 'paused';
      remoteDB = new rawPouch(portfolioConfig.remoteCouchURL);
      if (replicationHandle) {
        replicationHandle.cancel();
      }
      console.log("Performing continuous replication");
      replicationHandle = rawPouch.replicate(remoteDB, localDB, {
          live: true,
          retry: true,
          // Specify filter function manually.  Named filter functions (server-side) don't seem to work
          // filter: "replication/noattach"
          filter: replicationFilter
        })
        .on('change', function (info) {
          if (info.docs.length) {
            // Only if any docs were actually changed
            $rootScope.$emit('db-sync-complete');
            console.info('db sync change');
          }
        }).on('complete', function (info) {
          // NOTE: Not sure if this ever gets called - seems to be only the 'change' event
          $rootScope.$emit('db-sync-complete');
          console.info('db sync complete');
        }).on('error', function (err) {
          console.info('db sync error', err);
        }).on('active', function () {
          $rootScope.$evalAsync(function () {
            service.status = 'active';
          });
        }).on('paused', function () {
          $rootScope.$evalAsync(function () {
            service.status = 'paused';
          });
        });
    };

    var doInitialReplication = function () {
      console.log("Performing initial replication");
      service.status = 'active';
      return $q.when(localDB.load(portfolioConfig.initialReplicationURL, {
        // Ensure handoff works
        proxy: portfolioConfig.remoteCouchURL,
        // Same behaviour if filter is defined or not - filter applied in pouchdb-replication-stream already
        filter: replicationFilter
      })).finally(function () {
        console.log("Initial replication done");
        $rootScope.$emit('db-sync-complete');
        service.status = 'paused';
      });
    };

    // Check if we've done an initial replication
    localDB.get('_local/initial_load_complete').catch(function (err) {
      if (err.status !== 404) { // 404 means not found
        throw err;
      }
      return doInitialReplication().then(function () {
        // Save initial replication status for later calls
        return localDB.put({
          _id: '_local/initial_load_complete'
        });
      });
    }).then(function () {
      // at this point, we are sure that
      // initial replication is complete
      return startRegularReplication();
    }).catch(function (err) {
      // handle unexpected errors
    });
  };

Handoff to regular replication does not work?

Hey!
I have a remote db with 50,000 docs. When the user starts the webapp for the first time he has to download all docs, so I use pouchdb-load together with express-pouchdb-replication-stream to deliver the stream. The import works but after importing and then enable syncing, pouchdb makes 2000+ requests which takes several minutes. I guess it checks each document, so the proxy function does not work as intended. Here is my code:
http://pastebin.com/GciHNH8u
And here is the sync function:
http://pastebin.com/B2s65X9k

Optimize checkpointing when using for not read-only replications

I'm using this as a "fast start" for my cordova app.
The thing i would love to make faster is the "replicate.to(...)" step.

As pointed on the using instructions, after doing load(..), it must be passed to normal "replicate.from(...)". As i'm doing a two way replication (not read-only), i need to do "replicate.to(...) AND replicate.from(...)"...

I've found that in that scenario, i must wait a LOT for the upload part. See this:

Dump files: 10 txt files, taking 6.1 MB in size
Time spent on the db.load(...) for those 10 files: 15 secs.
Time spent on the db.replicate.to(...): 1.48 mins.
Time spent on the db.replicate.from(...): 38.41 secs.

So my intent is to make that 1.48 mins. MUCH lower.

@nolanlawson Hope this can be possible?

Strings larger than about 800 docs throw a JSON.parse() error

I'm trying to pass a string to load() because iOS won't load from a URL.
It happens on both Android and iOS. It attempts to parse a mystery line after the last line of the string at 4743 line = JSON.parse(line); but the mystery line appears to be a random part of the data, not split at a line break so it throws JSON Syntax Error. Is it a caching issue?

Loading from dump is become very slow with pouchdb v6.0.7 as compared to v5.4.5

We have dump files created with -s 5000 that creates individual dump files of 2-3 MB on average.
There are ~ 30 files, totaling to ~ 60MB of dump files.

We created an array of all those files and load them sequentially to create the single pouchDB.
When we used PouchDb v5.4.5 it completed the entire process of downloading and loading all files within 7 mins.
Now we upgraded to PouchDB v6.0.7 and the same code now takes around ~ 35 mins (almost 5X the time). The network bandwidth is almost the same.

Loading individual files benchmarks to approx 55 sec (~ 1 min) per files with v6.0.7, which used to take only few seconds with v5.4.5.

We are using the latest version of Pouchdb-load (v1.4.6).

Is this a known issue? This makes me feel to rollback to older version of PouchDb. But I send a lot of time to upgrade to v6.

Expected load times

What sort of load time should I be expecting for a 28mb dump file (51k docs) using the pouchdb-load plugin?

Many thanks,

Sam

Using proxy option in offline mode results in error

When I'm using the proxy option in an Ionic application with db.load, there's an uncaught error if the device is not connected to the internet. If I remove the proxy line everything works fine. Any ideas?

"Database encountered an unknown error" during replication on IOS

Pouchdb 5.1 is failing to replicate on IOS with error:

{\"status\":500,\"name\":\"unknown_error\",\"message\":\"Database encountered an unknown error\"}"

I also get this CORS warning:

"PouchDB: the remote database may not have CORS enabled.If not please enable CORS: http://pouchdb.com/errors.html#no_access_control_allow_origin_header"

AFAIU, there shouldn't be CORS warnings since I'm using:

<access origin="*" />

Besides, other databases are pulled without errors (though they were reading and writing 0 docs).

I'm using PhoneGap with this user agent:

Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 (400210848)

Same code works fine on Android, Chrome on Desktop.

Any hint?
Should I try an older version?
I'm using jsconsole and can run commands and do tests directly on the iPhone if necessary to debug.

New feature: make it work with file paths when on Node

Having some dumped .txt files on my filesystem, i would love to be able to load them to a new pouch on Node, but avoid the HTTP transport: just load the .txt directly from the filesystem? Would be that hard to implement this ?

Hope i'm not missing something, as i've found that .load uses ajax() to download the given URLS... not file paths, right?

Cheers @nolanlawson!

SyntaxError: Unexpected end of input {stack: (...), message: "Unexpected end of input"} message: "Unexpected end of input" stack: (...)

I get unexpected end of input when i try to load a external dump.
I had issues with CORS earlier. I fixed it by telling a php to send the CORS header first then send the dump file.

Here is my browser code below. Since the CORS is set to * the code can be run anywhere

//var PouchDB = require('pouchdb');
//PouchDB.plugin(require('pouchdb-load'));

var db = new PouchDB('santosh-transactions');
db.load('http://phone.tikoo.com/dump.php').then(function () {
console.log("hehe");
// done loading!
}).catch(function (err) {
console.log(err);
// HTTP error or something like that
});

Is it possible to load a database with indexes ?

Hi,

I don't know if it's possible but I have the following use case:

Offline mode on mobile:

Step 1. Load each database with https://github.com/nolanlawson/pouchdb-load
Step 2. Create indexes with https://github.com/nolanlawson/pouchdb-find with 'createIndex' method.

Is it possible to create indexes on the server side with CouchDB and load them with 'pouchdb-load' instead of creating them on the client side ?

I ask this question because it takes a lot a time to create indexes on the client side. Can we 'bundle' indexes in files generated with https://github.com/nolanlawson/pouchdb-dump-cli

Step 3 Online mode. Handoff to regular replication mode db.replicate.

Incomplete download

Hey guys,

I have a test dump data which is around ~300mb currently hosted in s3, and I have a proxy server created in express to handle file requests, in my request it seems like its only downloading/loading 28mb worth of data. But if i try to download it normally via axios/curl it seems to be alright.

Here is my code line using pouch load;

export async function startPouchDumpDownload(sourceDb, targetDb, opts, dump) {
  if (!(dump || {}).dump) return false;

  const loadDump = dump.dump;
  const loadDumpStatus = `_local/initial_dump_load_status_${loadDump}`;

  try {
    await targetDb.get(loadDumpStatus);
    console.log('@startPouchDumpDownload: Dump file has already been loaded', loadDump);
    return true;
  } catch (err) {
    console.error(
      '@startPouchDumpDownload: Error - getting load dump status - 404 is normal \n',
      'as its trying to check if it already downloaded the dump file \n',
      err,
    );
    if (err.status !== 404) return false;
  }

  try {
    const loadOpts = {
      // ...opts,
      proxy: sourceDb.name,
      ajax: {
        timeout: 999999,
        headers: { Authorization: dump.token },
        withCredentials: false,
      },
    };

    console.log('@startPouchDumpDownload: Loading initial dump file', loadDump);
    await targetDb.load(loadDump, loadOpts);
    await targetDb.put({ _id: loadDumpStatus });
    console.log('@startPouchDumpDownload: Loading initial dump file [done]', loadDump);
    return true;
  } catch (err) {
    console.error(
      '@startPouchDumpDownload: Error downloading dump \n',
      'handing off download to couch replication',
      err.message,
    );
    return false;
  }
}

Thanks in advance

add push_proxy option

If I am setting up a database that will have a push and pull replication, I want pouchdb-load to register a checkpoint for push replication as well.

As it currently works, after using pouchdb-load with the proxy option, the pull replication can get going straight away, but the push replication needs to run the checkpointer across the whole database.

This isn't necessary when the database is new and completely populated by load.

proxy does not work if "adapter" is set in target options [bug]

var db = new PouchDB('test', { adapter: 'websql' });
db.load('https://example.com/dump/dump_000001.txt", { proxy: "https://example.com/db" })
.then(function() {
  // this is never called
})
.catch(function() {
  // this is never called
});

In the logs, a websql database with the name "https://example.com/db" is created. I'm guessing it's extending it's options from the target's options.

TypeError: readableStream.pipe is not a function

I'm trying to use pouchdb with Ionic2. So far, everything seems to be working fine except pouchdb-load. I'm trying to load in a database from a dump file
(SEWRPC_ROOTRIVER@RACINE_2017-04-03.txt)
(previously exported to a text file using pouchdb-replication-stream and memory-stream, per your example).

Every time I run my app, the first time _db.load() runs, I get TypeError: readableStream.pipe is not a function when the app gets to the line with this._db.load(data); all subsequent runs (such as when navigating off the page then returning to the page and reading the text file again) succeed, and I see the data as expected. Any help or suggestions would be greatly appreciated!

Failure on first run:
capture1

Success on subsequent runs:
capture2

Code snippets:

sample-list.ts:

loadSamples(fileInput: any){
      let self = this;
      let selectedFiles = <Array<File>> fileInput.target.files || fileInput.dataTransfer.files;
      let reader = new FileReader();
      reader.onload = function(e) {
            self._sampleService.loadDB(reader.result);
      };
      reader.readAsBinaryString(selectedFiles[0]);
}

sample.service.ts:

import {Injectable}     from '@angular/core';
import PouchDB from 'pouchdb';
import PouchDBLoad from 'pouchdb-load';

@Injectable()
export class SampleService{
      private _db;

      constructor() {
            PouchDB.plugin(PouchDBLoad);
            this._db = new PouchDB('samples');
      }

      loadDB(data) {
            this._db.load(data).then(response => {
                  console.log("load done");
            }).catch( error => {
                  console.log(error);
            });
}

Environment:

  • Windows 7
  • Chrome 57
  • Firefox 52
  • Node 6.10.0
  • NPM 3.10.10
  • Typescript 2.2.2
  • Angular 2.2.1
  • Ionic 2.0.0
  • pouchdb 6.1.0
  • pouchdb-load 1.4.6

Hangs when used in conjunction with cordova-sqlite-storage plugin

With the cordova-sqlite-storage (v0.7.9) installed this plugin appears to hang (using pouch v4.0).

The 'then' and 'catch' functions are never called. The debugger shows:

      OPEN database: _pouch_database
      File: SQLitePLugin.js Line: 174, Column 15 

      new transaction is waiting for open operation
      File: SQLitePLugin.js Line: 105, Column 17

      DB opened: _pouch_database
      File: SQLitePLugin.js Line: 79, Column 15

      OPEN database: https://user:pass@url/database
      File: SQLitePLugin.js Line: 174, Column 15 

      new transaction is waiting for open operation
      File: SQLitePLugin.js Line: 105, Column 17 

I can give a code example if required.

Replication doesn't receive any change if DB is loaded with proxy option

It can reproduce in dev and If changing to not use proxy option, it works to normal. I don't find any difference in db.info() especially update_seq (both is 766) with vs without proxy option. The update_seq on remote server is 1355. As the app that is changed to use proxy option was just launched and user is starting to suffer the issue, do you think there is some remedy on the server side to make replication work again instead of releasing a new version of App changing back not to use proxy option, which would take longer due to holiday break? Thanks a lot for any help!

Proxy option not working when websql adapter used for local db

When your local db is created with this constructor:

new PouchDB('idstoneDB', { adapter: 'websql' });

the handoff to regular replication with proxy option does not work. This is becouse it tries to open proxy database with websql option as well, instead of use http o whatever.

This is my code:

var series = PouchDB.utils.Promise.resolve();

dumpFiles.forEach(function (dumpFile) {
   series = series.then(function () {
       return db.load(dumpFile,
       {
           proxy: 'http://192.168.0.101:4984/sync_db',
           auth: {
               username: 'userone',
               password: 'passwd'
           }
       }
   ).then(function (data) {
       // done!
   }).catch(function (err) {
       // HTTP error or something like that
   });
   });
});

series.then(function () {
   // done loading!
   return db.put({ _id: '_local/initial_load_complete' });
}).catch(function (err) {
   // HTTP error or something like that
});

I've tryed also forcing adapter to http, but it changes also the local db adapter option:

[...]
series = series.then(function () {
       return db.load(dumpFile,
       {
           proxy: 'http://192.168.0.101:4984/sync_db',
           auth: {
               username: 'userone',
               password: 'passwd'
           },
           adapter: 'http'
       }
[...]

pouchdb database dumps and portability

hey,

hoping you can help - chasing production release and getting lost in the docs a little bit!

i'm a bit confused about how pouchdb dump works perhaps you can help?

if i go through the process of:

  1. set up a couchdb database on https://couchdb.my.domain/test_db_01
  2. use pouchdb dump cli to create a dump of this
  3. use pouchdb instance bootstrapped with this dump to replicate https://couchdb.my.domain/test_db_01 to local database

that works great, and just starts updating from where the bundle left off

however, if i make a copy of the database to

  1. set up a couchdb database on https://couchdb.my.domain/test_db_01
  2. use pouchdb dump cli to create a dump of this
  3. use couchbackup to make a dump of the database
  4. use couchbackup to restore the database to https://couchdb.another.domain/test_db_01
  5. use pouchdb with the original dump to replicate https://couchdb.my.domain/test_db_01 to local database

struggling to understand the subtleties around moving these dumps around and what causes pouch to either pick up from the end of the dump or re-sync all the changes as if it were a new database.

hope you can help!

Dan

no data loaded

Warning: noob error probable!

My problem is that no data is loaded.

I built the dump using pouchdb-dump-cli. You can see a replicated copy of it here: http://46.101.166.244:5984/artendb/ae_objekte/ae_objekte.txt
It is a 340 MB file.

(the app is a CouchApp - so in order to serve the dump I attached it to a document - could there be something wrong with that?)

in app.js I set up the db like this:

app.extend({
  init () {
    this.localDb = new PouchDB('ae', function (error) {
      if (error) return console.log('error initializing local pouch ae:', error)
    })
  }
})
app.init()

In actions.js I'm setting up like this:

import PouchDB from 'pouchdb'
import pouchdbLoad from 'pouchdb-load'
PouchDB.plugin(pouchdbLoad)

I then do:

const url = 'http://localhost:5984/artendb/ae_objekte/ae_objekte.txt'
app.localDb.load(url)

or:

function filterFunction (doc) {
  if (doc.Typ && doc.Typ === 'Objekt') return true
  return false
}

const url = 'http://localhost:5984/artendb/ae_objekte/ae_objekte.txt'
const couchUrl = 'http://localhost:5984/artendb'
app.localDb.load(url, {
      proxy: couchUrl,
      filter: filterFunction
    })

No error occurs. But localDb remains empty.

I have also tried requesting the dump first using superagent (https://github.com/visionmedia/superagent):

request
  .get('http://localhost:5984/artendb/ae_objekte/ae_objekte.txt')
  .end(function (error, res) {
    // res.body is null!
  })

So no data arrived in the body?? This smells like some very nooby mistake to me.

I have added normal replication to take over after the load finished. This works - but ALL docs are replicated. I first thought it was because I had made a mistake with the proxy or the filter but it seems like it is because loading didn't work.

Load from HTTP endpoint /_all_docs

Loading from the dump seems useful, but why not get it right from the horse's mouth and use /_all_docs?include_docs=true as a straight source? As it stands, my app takes a few minutes to load from an empty PouchDB using its standard replication algos but _all_docs loads in seconds... I'd imagine it could also be just as fast if it was dumped into PouchDB in that manner.

Load/Restoring dump via web worker

Hi,

Is it possible to execute db.load() operation via web worker for SQLite database (cordova-plugin-sqlite-2)?
During restoring dump file (about 25Mb) UI hangs and it takes about 10 min.

More of a question than a bug, regarding the proxy and not re-downloading the file

In the docs this was mention:

This will tell the plugin that the dumpfile 'http://example.com/my-dump-file.txt' is just a proxy for 'http://mysite.com/mydb'. So when you pick up replication again, it won't start from 0 but rather will start from the last checkpoint reported by the dump file

But when I call "db.load" it seems that it downloads the file again as I can see it on my network tab. I only want it to download once if its already up-to-date with the sequence then don't re-download. If this is how it works then I could proceed to my backup plan to just use a flag. Else am I missing something?

Here is my sample code -

export function startPouchDumpDownload(sourceDb, targetDb, opts, dump) {
  if (!(dump || {}).dump) return false;

  const loadDump = dump.dump;
  const loadOpts = {
    ...opts, // filters, other opts for pouchdb, thinking the 'since' would work guess not 
    proxy: sourceDb.name, // Just a dbname nothing special
    ajax: { headers: { Authorization: dump.token } },
  };

  targetDb.load(loadDump, loadOpts).catch((err) => {
    console.error('@startPouchDumpDownload: Error', err);
    throw err;
  });

  console.error(`[${targetDb.name}] Source: ${sourceDb.name} | Dump: ${dump.dump}`);
  return true;
}

Local files in iOS

For local files, you can just use the filename and path in the url but for iOS a modification must be done.

line 188:
if ((xhr.status >= 200 && xhr.status < 300) || (xhr.status==0 && xhr.responseText.length>0) ) {

the additional or condition is because for some reason, iOS is returning 0 as the status for the xhr request even when there is data loaded from file. Maybe this is because file is not http but anyway now its working for Android, WP and iOS.

how to write checkpoints when loading splitted dump

My code loads a split dump like this:

const gruppeString = gruppe === 'Lebensräume' ? 'lr' : (gruppe === 'Macromycetes' ? 'pilze' : gruppe.toLowerCase())
app.remoteDb.get('ae-' + gruppeString)
  .then(function (doc) {
    return _.keys(doc._attachments)
  })
  .then(function (attachments) {
    let series = PouchDB.utils.Promise.resolve()
    attachments.forEach(function (fileName) {
      series = series.then(function () {
        const couchUrl = getCouchUrl()  // is: http://localhost:5984/artendb (local dev) or http://arteigenschaften.ch/artendb (production, untested yet)
        const loadUrl = couchUrl + '/ae-' + gruppeString + '/' + fileName
        // TODO: looks like no checkpoint is set, so following replication takes forever
        return app.localDb.load(loadUrl, {proxy: couchUrl})
      })
    })
    series.then(function () {
      resolve(true)
    })

Real code here: https://github.com/barbalex/ae/blob/master/src/modules/loadGroupFromRemote.js

When the promise resolves, replication is started for the loaded subset of docs:

app.localDb.replicate.from(app.remoteDb, {
  filter: function (doc) {
    return (doc.Gruppe && doc.Gruppe === gruppe)
  }
})

Real code here: https://github.com/barbalex/ae/blob/master/src/actions.js#L98-L102

The problem is: A checkpoint was not written, or so it seems, because pouchdb starts thousands of changes requests to the remoteDb.

After this replication the checkpoint was written thought: if I start replication a second time (manually) it finishes after only two requests to the remoteDb.

Am I doing something wrong?

Or does the proxy setting only work when a dump was not split?

I do see that the split files are loaded from last to first. So if pouchdb overwrites the checkpoint every time it loads one of the split files, there will be a checkpoint but most of the replication will still happen.

Update: I changed the sorting of the split files. The one with the last docs is now loaded last. Replication still takes forever.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.