Will mongoose support initializeOrderedBulkOp() which is a new feature in Mongo DB – 2.6

Am using mongoose – 3.8.8 to connect to Mongo DB. I tried out initializeOrderedBulkOp() – a new feature of MongoDB – 2.6 in mongo Shell and i got proper output. But am not able to do the same with mongoose.
Here is a sample code

var mongoose = require('mongoose');
var conn = mongoose.createConnection('mongodb://localhost:27017/testDB');  
conn.on('error', function callback (err,data) {
    console.log('Error in connecting to DB');
});

var Schema = mongoose.Schema,  
    schema = new Schema({id:Number},{strict:false}),  
    modelObj = conn.model('', schema, 'documents');

var query = modelObj.initializeOrderedBulkOp(); 

Am getting error like “modelObj has no method ‘initializeOrderedBulkOp”
Any suggestions on this ???

  • Issue in returning data retrieved from DB queries called in the loop
  • Update multiple docs with different values
  • JS node asynchronous handling of events
  • Nodejs/mongodb- Checking if a user has Admin privileges (token based auth)
  • Express: mongodb mongoose linking entities
  • Can't populate big chunk of data to mongodb using Node.js
  • mongoose. updating embedded document in array
  • Check mongoose connection state without creating new connection
  • Show BASE64 video with node/express
  • How to receive the socket.io client side event in node.js?
  • Short user-friendly ID for mongo
  • MongoDB, remove object from array
  • One Solution collect form web for “Will mongoose support initializeOrderedBulkOp() which is a new feature in Mongo DB – 2.6”

    You’re really close. You need to drop down a level to the native driver. You can do that like so:

    var query = modelObj.collection.initializeOrderedBulkOp(); 
    

    From there you can do things like:

    // queue a doc to be inserted
    query.insert({ name: 'Some Name' })
    
    // ... more inserts ...
    
    // execute the bulk operation
    query.execute(next)
    

    One thing to note though, the un-ordered equivalent, initializeUnOrderedBulkOp(), does not seem to exist in version 3.8.9.

    Node.js is the Best Javascript runtime in the world.