问题
I have a news base that needs to work online and offline. I'm using CouchDB (IBM Cloudant ) and PouchDB to make this sync with the APP.
The problem is that the news is relatively "heavy" for having photos and am having sync problems because the size of the "docs", and does not see any need to synchronize all the news base, will only fill the user's mobile phone with unnecessary records.
I need to sync only some news, approx. five registers. I wonder how can I do this in CouchDB or PouchDB.
I looked in sync + filters documentation but does not answer me the question of the amount of sync docs (or at least did not see if it is possible).
I'm using a view to pull the news.
回答1:
Since you're using a view to pull the news, you can use limit
to limit the number of documents you fetch. You can also use since
to determine when you need to fetch the next batch of documents (this will have to be executed periodically to check for the existence of new documents)
If you go down this route and if your app doesn't need need client -> server replication then you could use something lighter than PouchDB do store the documents and other info on the client.
回答2:
Yes you can, use filtered replication for this: https://pouchdb.com/api.html#filtered-replication
Credits: Nolan Lawson (PouchDB core team).
来源:https://stackoverflow.com/questions/38834877/limit-records-synchronized-in-pouchdb-couchdb