I want to save array of objects in MongoDB in my Meteor app and I'm also using Meteor astronomy for manage Mongo collection
My array of objects like this
[
{
"id" : "aaaa1",
"make" : "toyota",
"year" : "2005",
"model" : "prado",
},
{
"id" : "aaaa2",
"make" : "toyota",
"year" : "2005;2006",
"model" : "fortuner",
},
{
"id" : "aaaa3",
"make" : "toyota",
"year" : "2005;2006;2007;2008",
"model" : "axio",
},
]
I used map function to loop through the array and save data, but it only saves the last record. Here is my code
array.map((row) => {
console.log(row.type);
vehicleDb.set({
make: row.make,
year: row.year,
model: row.model,
});
vehicleDb.save( function (error) {
// console.log(error);
});
});