19 lines
526 B
JavaScript
19 lines
526 B
JavaScript
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});
|
|
})();
|