I am working on an app which stores data locally using PouchDB. It displays a list of items and I would like to be able to check if the database is empty so that in the case that it is, I can append a line 'Your list is empty' to the DOM. Is there a way to do this?
There are several ways to do this. You could query and check for an empty result list. You can also use db.info()
.
db.info().then(function (result) {
if(result.doc_count === 0) {
console.log('It's empty!');
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.