_id and ObjectId

noun

say it: “UN-der-skor EYE-DEE and OB-jekt EYE-DEE” /ˈʌndərskɔr ˌaɪ ˈdi ənd ˈɑbdʒɛkt ˌaɪ ˈdi/

_id is the field that identifies each MongoDB document; an ObjectId is the unique value MongoDB gives it when you don't.

What is _id and ObjectId?

Every document has an _id. If you don't set one, MongoDB creates an ObjectId: a 12-byte ID that is unique and roughly sorted by creation time.

In a sentence

  • “Every plant document got an _id the moment it was inserted.”
  • “The route turns the text in the address into an ObjectId before searching by it.”

Level: Novice · More MongoDB terms at this level

Updated