Closed bwgjoseph closed 3 years ago
@bwgjoseph will need to discuss it more will shelve it for future
same for updateMany()
@httpJunkie @AV25242
To further iterate on this issue with the assumption of the database already having 100 documents,
createMany
with 10 docs, I have no idea which are the 10 documents created now that there are 110 documentsupdateMany
with the filter, it could update 50 documents but I have no idea which 50 documents are those that has been updatedremoveMany
with the filter, it could remove 40 documents but I have no idea which 40 documents are removedThe removeMany
is slightly different from the removeById
case where I do know which id
I passed into the API for deletion. In removeMany
case, I do not know what are removed
Hence, I would think this is a critical issue for the API instead of a future issue, otherwise, the API wouldn't be of much use
Some reference
mongoose
there's create and insertMany API, where both accepts an array of doc and both returns the created document by defaultupdate
and remove
, I suppose one temporary solution is to perform a find
using the filter, before calling the update
or remove
to grab the data (ids) first then after the update
or remove
operation is done, then query it again using those ids
but it may not be accurate if there is changes between getting the ids
first, and then using those ids
to get later after the operation as in between this two operations, the data may have already been changedThe issues are created to investigate viable options and see if this is feasible.
I thought this is available to you know please review and let me know.
Sorry, might have missed this. Will take a look later
Have verified it
Hi,
Is it possible to return the docs that were created/updated/removed in the *Many operations instead of the
ManyQueryResponse
when a param is passed in such as (for example)new: true
orraw: true
?or alternatively, appending the raw result from the creations onto
ManyQueryResponse
like