Open JcBernack opened 8 years ago
Interesting... I'm on the fence but leaning towards implementing something that checks the doc._id for changes and then passing that back. I'll think more on it but i think the behavior you're asking for makes sense.
Thanks for the response!
To give a little more background: I was trying to keep the collection in sync with an SQL table. The idea was to insert the documents into the SQL table in the before.insert hook and set the ID to the one generated on the SQL side. That actually worked great, until I found out that it's impossible to find out the new ID.
I have the same problem. How to solve? Please example.
I want to change the _id of a document in a before.insert hook.
The document with the changed id is correctly inserted into the collection, but the return value of the
insert
call still is the original id. Even when using the callback toinsert
on the server there is no way to get the generated id. This way the caller is unable to find out the id of the newly inserted document.Example:
The output then is: