const { client, connectToMongo } = require("./mongo.js");
async function insertData() {
try {
await connectToMongo();
const db = client.db("test");
const collection = db.collection("student");
const data = {
name: "olee",
roll: 23,
};
const result = await collection.insertOne(data);
console.log("Inserted document with _id: " + result.insertedId);
} catch (err) {
console.error(err);
} finally {
// Close the connection
client.close();
}
}
insertData();