Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { MongoClient } from "https://deno.land/x/mongo@v0.8.0/mod.ts";
const client = new MongoClient();
client.connectWithUri("mongodb://localhost:27017");
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