Mongodb instanceof and typeof cannot be used in the shell

How to use it? It cannot be used as a command alone, db.coll._id instanceof ObjectId will be equal to false, and the document will return true. And typeof returns undefined, no, so how do you use these two operations to operate ni?

Hi @111117,

Welcome to MongoDB community!

I think it needs to be operated on a variable:

var mydoc = db.coll.findOne();
typeof mydoc._id

Thanks
Pavel

Okay thank you :grinning:

1 Like