Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ObjectID is not defined. Cannot find object by id in Mongo Shell

Tags:

mongodb

I tried to google my simple problem, but cannot find answer. I can't find any object by it's ObjectId.

db.user.find({_id:ObjectID("57fa0a15cf1e8c0e571e1a52")})

ReferenceError: ObjectID is not defined

Why? What is wrong?

like image 778
Saturn Avatar asked Oct 09 '16 09:10

Saturn


1 Answers

It should be ObjectId() not ObjectID() https://docs.mongodb.com/manual/reference/method/ObjectId/

like image 160
Oleks Avatar answered Nov 11 '22 05:11

Oleks