Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-2751

Backport: Ability to use arrayfilters() with bulk operations

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.0
    • Affects Version/s: 3.6.0, 4.0.0
    • Component/s: Native, Shell
    • Environment:
      Windows NodeJS

      Mongodb Manual Reference has provided below example:

       

      var bulk = db.coll.initializeUnorderedBulkOp();
      bulk.find({}).arrayFilters( [ { "elem.grade": { $gt: 85 } } ] ).updateOne( { $set: { "grades.$[elem].mean" : 70 } } );
      bulk.execute();
      

      When executing this function in node.js with mongodb npm, its giving an error,

       

      TypeError: bulk.find(...).arrayFilters is not a function
       at updateDocuments (path\index.js:21:14)
       at processTicksAndRejections (internal/process/task_queues.js:93:5)
      

       

      Note: its working successful in mongo shell

      Mongodb Version: 4.2
      Mongodb NPM: 3.6.0
      Node JS: 12.x


      As per last fix NODE-1911,

      It is working this way.

      db.coll.updateOne(
       {},
       { $set: { "grades.$[elem].mean" : 70 } },
       { arrayFilters: [ { "elem.grade": { $gt: 85 } } ] }
      );
      

       

       

            Assignee:
            eric.adum@mongodb.com Eric Adum (Inactive)
            Reporter:
            turivishal@gmail.com Vishal Turi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: