如何在cblite api的帮助下找出来自cblite数据库的文件是否已在android上复制? 遇到这个链接,但没有任何意义。 Pouchdb. How to verify a doc is replicated
答案 0 :(得分:0)
在cblite db中,每个文档都有一个序列号,每当复制每个文档时,都会为文档分配序列号。这是为了更好地理解这段代码,
//Get the latest sequence number of the document replicated
lastSeq = rep.getLastSequence();
Query query = database.createAllDocumentsQuery();
QueryEnumerator rowEnum = query.run();
for (Iterator<QueryRow> it = rowEnum; it.hasNext();) {
QueryRow row = it.next();
if(lastSequence!=null)
{
if(Long.parseLong(lastSequence)>=row.getSequenceNumber())
{
purgeDoc = row.getDocument();
purgeDoc.purge();
}
}
}