Closed ArnaudParant closed 10 years ago
Hi @ArnaudParant
Basically, I would not really want to do it.
MongoDB itself has a default fire and forget mechanism. Basically, for every write, you just send the write/insert
command to MongoDB via socket, and then forget. There will be no confirmation returns back. That's why the insert
is designed to return unit.
So, if your MongoDB has been setup in this default way (fire and forget), then if you want insert
to return the id, then what I have to do is after real insert, constantly query mongodb for the exact doc list that were just inserted. It is an ugly way, isn't it? and also I have to block the function.
Even if your MongoDB has disabled the fire and forget, I still need to query.
For your need, I suggest you can have your own id property, and build index on that property, and maintain the _id_s in your application. It is the same thing.
Hi @MassD
Thanks for this explanation. So I think I will create my own id, you're right.
Hello,
The insert function from the Mongo module return unit. Is it possible to return the created documents ? I will allow to get the id of the created documents for example, so it could be very useful.