Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import { MongoClient } from "";
const client = new MongoClient();
const db = client.database("test");
const users = db.collection("cities");
// insert
const insertId = await users.insertOne({
name: "Delhi",
country: "India",
population: 10000
console.log(`Successfully inserted with the id: ${JSON.stringify(insertId)}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment