Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 PouchDB 创建一个离线应用程序。现在我正在加载数据库并发布几行,但这意味着每次加载时这些行都会重复。是否有用于初始化和预填充数据库的标准模式?如果我想更新增加未来预填充的数据量怎么办?
我能想到的最好方法是获取 total_rows 以确保它是否达到您的限制,如果没有,则向其发布更多项目,否则,请执行您需要做的任何事情。这可确保您不会获得重复的数据。
DB.allDocs({include_docs:true}, function(error, response) { if(response.total_rows != YOURMAXLIMIT) { // Add more items } });