couchdb-net
couchdb-net copied to clipboard
FindManyAsync returns deleted documents, but not sure how to identify them?
FindManyAsync seems to return deleted documents, Is there currently a way to identify if the document is deleted or not?
If not would it be possible to expose _deleted=true on the CouchDocument for example.
Thanks
Hi, that's a tricky one. Is that correct that the DB returns deleted documents in the first place?
The FindManyAsync method, uses the _bulk_get CouchDB endpoint, if I use Thunder Client/Postman and pass a deleted document id, such as:
{
"docs": [
{
"id": "rb-ct002110:017d33dd6cf4476f9e6e8604fd436c73"
}
]
}
I get the following result:
{
"results": [
{
"id": "rb-ct002110:017d33dd6cf4476f9e6e8604fd436c73",
"docs": [
{
"ok": {
"_id": "rb-ct002110:017d33dd6cf4476f9e6e8604fd436c73",
"_rev": "2-8006f354c92f25ef9cf4aa630fac35fc",
"_deleted": true
}
}
]
}
]
}
I trust you, what I am saying, can it be a CouchDB bug or missing setting on DB level?
I am asking because it's not documented on their end
I'm guessing it's by design, but poorly documented, there's some information on the _delete flag here:
https://docs.couchdb.org/en/stable/api/document/common.html#get--db-docid https://docs.couchdb.org/en/stable/ddocs/ddocs.html https://docs.couchdb.org/en/stable/replication/conflicts.html https://docs.couchdb.org/en/stable/api/database/misc.html
The most convincing bit would probably be the first link where it documents the GET /{db}/{docid} endpoint and describes the flag as _deleted (boolean) – Deletion flag. Available if document was removed.
However, further down the document the following section seem to suggest you need to supply a rev to retrieve the deleted document (I've not tried this, so I can't confirm, but if that is the case then maybe the _bulk_get function is suppose to work the same way and there is a genuine bug with it?):
https://docs.couchdb.org/en/stable/api/document/common.html#retrieving-deleted-documents
https://github.com/apache/couchdb/discussions/3849
https://github.com/apache/couchdb/issues/3608#issuecomment-873263210
Hi,
I've added the following to properties to my document as a workaround until this gets fixed:
// We add this property to detect deleted field returned from the _bulk_get endpoint
// https://github.com/matteobortolazzo/couchdb-net/issues/154
[JsonProperty("_deleted")]
private bool NativeDeleted {
set => Deleted = value;
}
[JsonIgnore]
public bool Deleted { get; set; } = false;
Hi, I think we can add a parameter to filter out delete documents
It took a lot, but I added the property :)