I want to get the id of a created document without having to make a separate query to get the document after it is created. I’m thinking I’ll need to manually create the id of the document before creating it. Is there a way to do this? I’m using the mongoose driver.
I want to get the id of a created document without having to make
Share
Once you create a new mongoose model instance, its
_idvalue is already set to what it will be when saved. For example: