first commit
This commit is contained in:
18
test.js
Normal file
18
test.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import clientPromise, { objectId, database } from "./src/db.config.js";
|
||||
import data from "./test.json" with { type: "json" };
|
||||
|
||||
// Dimas Comment
|
||||
|
||||
(async () => {
|
||||
const client = await clientPromise;
|
||||
const db = client.db("web");
|
||||
const analytics = db.collection("analytics");
|
||||
|
||||
const _Data = data.map(item => {
|
||||
delete item._id;
|
||||
return { ...item, timestamp: new Date(item.timestamp)}
|
||||
})
|
||||
|
||||
const result = await Promise.all(_Data.map(async (item) => await analytics.insertOne(item)));
|
||||
console.log({result});
|
||||
})();
|
||||
Reference in New Issue
Block a user