Skip to content

Instantly share code, notes, and snippets.

View bansalvks's full-sized avatar

Vikas Bansal bansalvks

View GitHub Profile
@bansalvks
bansalvks / bulk-import.js
Last active September 19, 2021 04:56
mongodb bulk import nested array of objects with new ObjectId
const { MongoClient, ObjectID } = require("mongodb");
// Replace the uri string with your MongoDB deployment's connection string.
const uri = "MONGODB URI";
const client = new MongoClient(uri);
const data = {/** data you want to import */}
function addObjectIdToArrayItems(target) {