Closed H--o-l closed 4 years ago
If I understand you correctly, you can achieve the wanted behavior with the create
parameter.
# List of ids that may or may not exists.
ids = ['toto', 'titi']
ok_doc = []
nok_doc = []
async for doc in db.docs(ids=ids, create=True):
if doc.exists:
ok_doc.append(doc)
else:
nok_doc.append(doc)
Thanks @bmario it's a nice idea! I have just one question just to be sure, I don't want to create the document, can you confirm it will not create it as long as I don't save it, is that it?
I have tested and I can answer to myself: as long as I don't save the un-existing document it does not create it. I'm closing this issue, thanks @bmario !
I have just one question just to be sure, I don't want to create the document, can you confirm it will not create it as long as I don't save it, is that it?
Yes, indeed. Documents will only ever be created on the server, when you call the save()
method.
Hey! Thanks for this extra-cool library.
Sometime it's needed to fetch a precise list of documents, but without knowing if they exist or not. CouchDB itself allow that, with
POST /_all_docs
. For each returned row, there is either:But aiocouch API catch the error, raise an exception, and stop its async generator: https://github.com/metricq/aiocouch/blob/9d9ae99ba6b3b44b11358c59822529d3982de0d6/aiocouch/view.py#L109-L112
It then become really hard to further process the result, and do something with documents that does exists.
It also seems impossible to workaround it, without calling
RemoteView
itself.One example of what could be the usage:
Do you have an idea how it could or should be implemented? I'd be happy to contribute!