From mongosh to the Driver: find, insertOne and toArray

Every mongosh query has a twin in the Node.js driver, written with db.collection("pets"), await, a projection inside an options object, toArray() to read a cursor, and new ObjectId(id) imported from the driver, and insertOne gives back the new document's insertedId.

By

Updated

Cheat sheet: From mongosh to the Driver: find, insertOne and toArray
Category
MongoDB
Level
Journeyman
Tags
_id and ObjectId, Cursor (mongodb), find (mongodb), insertOne and insertMany, mongodb, nodejs