Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 24, 2020 13:07
Show Gist options
  • Save velotiotech/6e0428333c15b3ff2efb6a6dde760103 to your computer and use it in GitHub Desktop.
Save velotiotech/6e0428333c15b3ff2efb6a6dde760103 to your computer and use it in GitHub Desktop.
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