With the new release from Couchbase Lite the Document and DocumentID properties have been removed and replaced with a new IResult as return value. However To Purge (completely remove) a document from your database, the purge() method still requires a Document object. My question: is how do you obtain this object of type document from the IResult you get from the query you executed? Couchbase also announced that Document might make a return in the future.
The query result is in the format specified in the SELECT clause. You can get that property by it’s name (row.string(forKey: "id")) or position in the SELECT clause (row.string(at: 0) in your example).
Curious - Is there a reason you are manually purging a document ? Couchbase Lite has built in logic to purge old and unused revisions . As you may probably know, purges are not replicated which means the document can reappear in your database through a pull replication for instance, if another client updates it.
I am currently testing the CRUD operations so im still learning how it all works.
What is the correct way to remove a document from the database locally and server-side?
You mentioned that CBL automatically purges old & unused revisions. but what if i want to manually remove a document. for example a student has changed class. so he/she has to be removed (purged) from the database of students he/she is currently in and added into another. As fast as possible
Im just looking for a way to completely remove a document forgood.
i already managed to select documents and show them in a list. (these documents come from the server). so i got replication going. but still i sometimes get the same problem as before… see my other topic about this => replication failure
Hi - Use delete instead of purge if you want to remove the document and have that change replicated. Delete will tombstone a revision so its marked as deleted. The JSON body will be removed.
If you would like to learn more about pruning and compaction, this blog may be a good read .