How to remove emmited documents from View at CouchbaseLite



I am pulling document from Sever every 2-3 min later . I am updating view for mapping new documents . But i want to remove previous emmited docs from that view . How will i do it?


Not sure what you’re asking. You want older documents not to appear in queries?


yes. When i create a View , i create a Map and into Map, i save a document then i create query. I want to remove previous saved document when i update map version .


If you want to remove a document locally, you can use the purge method.

A view indexes the entire database, just as a SQL index does. If you want to query only a subset of the documents, you need to design a key that will let you do that. For example if your documents have a timestamp, you can use the timestamp as the key (or as the first element of an array key). Then you can query for results with only timestamps greater than some cutoff time.


If you’re talking about the map functions for a view, when you change the map you should change the version number. That will invalidate the index, which means all old docs saved will in the index will get flushed. You’d want to have the docs purged from the local database first.

By the way, you generally don’t want to emit the whole document when creating a view. Of course there are exceptions, but just wanted to point that out as a best practice.