top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the structure of ObjectID in MongoDB?

0 votes
260 views
What is the structure of ObjectID in MongoDB?
posted Feb 14, 2017 by Gaurav

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

Im just doing CRUD on a mongo database with Java. My problem is when I query the database

db.getCollection("something").find()

I get the documents correctly, but the ObjectId of each document is something like this:

"_id": {
  "timestamp": **********,
  "machineIdentifier": 16375804,
  "processIdentifier": 3908,
  "counter": 9920756,
  "time": 1459641911000,
  "date": "2016-04-03T00:05:11.000+0000",
  "timeSecond": **********
}

I need to get the 12-byte ObjectId, like this:

ObjectId("507f1f77bcf86cd799439011")

How do I do that?

...