What is the best way to delete/update data in document couchbase ios?



I have a message document for storing messages. Each message is matched with unique post id.
Every time I need to delete/update, I first convert the whole document into dictionary. Then I remove or update the message based on post id. In the end, I insert dictionary back to database. This way is very slow (1 sec ~ 2 sec). I wonder if there is a better way like SELECT query?

Thank you very much


Which version of CBL are you on ?



I am using version 2.0
Thank you


Something to consider - split individual posts into separate documents and link it to the top level message document that will hold list of postIds. Basically use reference model instead of embedding everything in one document. That way you can updating individual post documents without affecting the main message document.
You can then use JOIN to query between the message and post documents based on post Id. Here is a quick primer