KeplerGrid guide

Query a MongoDB ObjectId with Extended JSON

Match a BSON ObjectId exactly and distinguish it from a string with the same characters. Use the embedded timestamp only when it fits your data.

Load the practice collection

Run once in mongosh against a development instance with an empty records practice collection.

const lab = db.getSiblingDB("keplergrid_practice")
lab.records.insertMany([
  { _id: ObjectId("69cc60000000000000000001"), label: "typed ID" },
  { _id: "69cc60000000000000000001", label: "string ID" },
  { _id: ObjectId("69cdb1800000000000000002"), label: "next day" }
])

In KeplerGrid, open keplergrid_practice.records with a Read only connection.

Look up a document by its BSON ObjectId

Paste the filter into KeplerGrid Documents. The $oid wrapper tells the editor to preserve the BSON ObjectId type.

{ "_id": { "$oid": "69cc60000000000000000001" } }

Only typed ID matches. A plain quoted hexadecimal string would match string ID instead. A document can use either type for _id.

Filter by the timestamp embedded in the ID

The first eight hex digits hold the timestamp in seconds. These lower and upper bounds pad the remaining bytes with zeros for the UTC starts of April 1 and April 2, 2026.

{
  "_id": {
    "$gte": { "$oid": "69cc60000000000000000000" },
    "$lt": { "$oid": "69cdb1800000000000000000" }
  }
}

Only the first ObjectId falls in this range. The embedded timestamp describes ID generation, which can differ from the document’s event or insert time. Use a dedicated BSON Date field when the business timestamp matters or IDs may use different types.

See how to query a dedicated BSON date field with UTC boundaries or revisit the related KeplerGrid walkthrough.