Limit records synchronized in PouchDB/CouchDB

混江龙づ霸主 提交于 2019-12-12 12:04:59

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!