I am trying to insert multiple documents into a collection in mongoDB database, but am only getting only one object ID as response (multiple documents are getting created in the DB).
Code:
exports.createRelation = function(relationDoc, db, callback) {
var relations = db.get("relations");
relations
.insert( relationDoc )
.error( function ( err ) {
callback(err, null);
})
.success( function ( doc ){
callback(null, doc);
});
};
in this the relationDoc would be an array
Input:
newRelDocs_Array: [ {
path: [ 53d0b191c5ac61d403b0090d ]
tob: 1405343247 },
{
path: [ 53d0b191c5ac61d403b0090d ],
tob: 1405343247 } ]
Response :
createRelation(): Success
createRelation_db: {
_id: 546a1d6f65c05d1c37660c4c,
tob: 1405343247
}
FYI, I am using NodeJS, and connection to MongoDB with monk.