From cba475784b4d28d6de80c4aa955dfd6283be9c58 Mon Sep 17 00:00:00 2001 From: 10023r Date: Tue, 26 Sep 2023 22:34:49 +0300 Subject: [PATCH] hello_world task: done --- hello_world/index.js | 20 ++++++++++++++++++++ hello_world/package.json | 14 ++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 hello_world/index.js create mode 100644 hello_world/package.json diff --git a/hello_world/index.js b/hello_world/index.js new file mode 100644 index 0000000..34b9b18 --- /dev/null +++ b/hello_world/index.js @@ -0,0 +1,20 @@ +const {MongoClient} = require('mongodb') + +const client = new MongoClient("mongodb://127.0.0.1:27017/") + +const start = async () => { + try { + await client.connect() + console.log("Connected to mongo") + await client.db().createCollection("Tmp") + const users = client.db().collection("Tmp") + await users.insertOne({text: "Hello world!"}) + const user =await users.findOne({text: "Hello world!"}) + console.log(user) + client.close() + } catch (e) { + console.log(e) + } +} + +start() diff --git a/hello_world/package.json b/hello_world/package.json new file mode 100644 index 0000000..b5e0951 --- /dev/null +++ b/hello_world/package.json @@ -0,0 +1,14 @@ +{ + "name": "dentist_project", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "mongodb": "^6.1.0" + } +}