-
사전 준비
npm install mongodb
예제
const { MongoClient } = require('mongodb'); const mgct = new MongoClient("mongodb://yourid:password@127.0.0.1:27017"); const db1 = mgct.db("Db1"); const clc1 = db1.collection("Clc1"); let id = "id1"; const doc = { id: id, title: "Record of a Shriveled Datum", content: "No bytes, no problem. Just insert a document, in MongoDB", }; const result = await clc1.insertOne(doc); const movie = await clc1.findOne({id:id}); console.log(movie);
'Mongodb' 카테고리의 다른 글
drop database, db 삭제 (0) 2023.01.12 Cursor Methods (0) 2022.12.27 Find (FindOne) (0) 2022.12.27 Update (UpdateOne, UpdateMany) (0) 2022.12.27 help command (0) 2022.12.26 MongoDB Shell (0) 2022.12.26 MongoDB user 추가 (0) 2022.12.24 MongoDB 접속 명령 (1) 2022.12.24