npm i
deno run --unstable --compat --allow-all index.j
Created
March 9, 2022 18:43
-
-
Save kevincennis/42563f84a1918f1026f3df8110149ac0 to your computer and use it in GitHub Desktop.
deno node compat mongo demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MongoClient = require('mongodb').MongoClient; | |
const url = 'mongodb://localhost:27017/denotest'; | |
const opts = { useNewUrlParser: true, useUnifiedTopology: true }; | |
async function main() { | |
const client = await MongoClient.connect( url, opts ); | |
const db = await client.db(); | |
const coll = await db.collection('testypoo'); | |
const res = await coll.insertOne({ foo: 'bar' }); | |
const doc = await coll.findOne({ _id: res.insertedId }); | |
console.log( doc ); | |
await client.close(); | |
} | |
main().then( console.log, console.error ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "denomongo", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"mongodb": "^4.4.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment