Skip to main content

How do I work with ObjectId in Atlas UI, Mongo shell, Compass and App Services Function?

Syntax examples to query ObjectID in different MongoDB Products

Written by Joao Boesso
Updated over 2 years ago

ObjectId in the Date Explorer of Atlas UI

To work with ObjectId in the Date Explorer of Atlas UI, use the syntax {"$oid": "<ObjectId bytes>"} as specified in the documentation. See the example below:

ObjectId in the Date Explorer of Mongo shell and Compass

To work with ObjectID in Mongo Shell and Compass, use the syntax ObjectId("<ObjectId bytes>"). See the example below:

ObjectId in an App Services function

To work with ObjectID in an App Services function, use the syntax new BSON.ObjectId("<ObjectId bytes>") as specified in the documentation. See the example below:


​

Did this answer your question?