RawSushi's Tech Journal
My online tech scrapbook where I keep my notes in case I need to look them up later
Thursday, September 6, 2012
MongoDB: Get ID of Inserted Document
After inserting, use the following:
DBObject dbObj = new BasicDBObject(valuesMap);
collection.insert(dbObj);
ObjectId id = (ObjectId)dbObj.get("_id");
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment