I was wondering how to query for documents that are not flagged for deletion. I could iterate the result but is there a direct approach
My best guess was
using (var database = new Database(DbName))
using (var query = Query.Select(SelectResult.Expression(Expression.Meta().ID))
using (var results = query.Run())
var returnedIds = results?.Select(x => x.GetString("id")).ToList() ?? null;
if (returnedIds != null)
returnedIds.ForEach(id => documents.Add(database.GetDocument(id)));
It’s actually a bug that queries return deleted documents. The fix will be in the next DB.
(I’ve considered whether there should be an option to be able to filter them out yourself, but I suspect there are few cases where people will want to search deleted documents … if you have a need to, let me know.)
Exactly this is what I think too. _deleted is a kind of soft delete in the system. But what if I want to purge all tombstone documents to save space ?
That’s a very good point, actually — there needs to be a way to find deleted docs in order to purge them.
Database has an allDocuments method but unlike 1.x it has no options for things like whether or not to include deleted documents. I’ll file an issue.