Reputation: 11
I have a collection that requires fields that are from calculations. I completed the calculations and stored the results in variables. However, I can not insert all the variables into the collection, it only adds the first variable.
For example: db.foo.insert(a,b,c);
a, b, c being javascript variables.
How would I fix this to print all variables in mongoDB format? The variables look like: var a = {"sum": 14}
Upvotes: 0
Views: 211
Reputation: 1833
Perhaps you are looking for insertMany()
function.
In your case that would look something like this:
db.foo.insertMany([a, b, c])
Here is the link to the official docs.
Upvotes: 1