반응형
Computer Science/데이터베이스
-
[ MongoDB ] 기본 CRUDComputer Science/데이터베이스 2023. 5. 11. 20:13
import { MongoClient } from "mongodb"; export async function insert(dbName, collectionName, data) { //create 생성 const client = new MongoClient(process.env.URL); try { //client 연결 await client.connect(); //database, collection 설정 const database = client.db(dbName); const collection = database.collection(collectionName); // try { await collection.insertMany([data]); console.log("insertion complete..