Is there any way to get last inserted ObjectId? i can't find it on their documentation or maybe i am not digging far enough, thanks.
Asked
Active
Viewed 124 times
1 Answers
2
The insert method will mutate the underlying DBObject and add a _id
field if it doesn't exist.
> val document = MongoDBObject("{x: 101}")
> collection.insert(document)
> println(document)
{ "x" : 101 , "_id" : { "$oid" : "58204e47e9dd35767edb0225"}}
So you can check your inserted document for the _id

Ross
- 17,861
- 2
- 55
- 73