const { MongoClient } = require("mongodb");
const url = "mongodb://localhost:27017";
const client = new MongoClient(url);
const dbName = "user_shopping_list";
// Use connect method to connect to the server
console.log("Connected successfully to server");
// Create the database for our example (we will use the same database throughout the tutorial
const db = client.db(dbName);
const collection = db.collection("user_1_items");
batch_number: "RR450020FRG",
category: "kitchen appliance",
item_description: "brown country eggs",
const insertResult = await collection.insertMany([item_1, item_2]);
console.log("Inserted documents =>", insertResult);
ingredients: "all-purpose flour",
expiry_date: "2021-07-13 00:00:00",
await collection.insertOne(item_3);
.finally(() => client.close());