[SERVER-61618] bulkUpdate $pull operation on array with objects not working Created: 19/Nov/21  Updated: 19/Nov/21  Resolved: 19/Nov/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.4.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ivan Cherviakov Assignee: Unassigned
Resolution: Done Votes: 0
Labels: Bug
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

 

import { MongoClient } from 'mongodb'
 
const client = new MongoClient('mongodb://127.0.0.1:27017')
await client.connect()
const db = client.db('test')
const insertResult = await db.collection('test').insertOne({ arr: [{ _id: 1, isAdmin: true }, { _id: 2, isAdmin: false }] })
const doc = await db.collection('test').findOne({ _id: insertResult.insertedId })
console.log('before bulk update', doc)
const bulkUpdate = db.collection('test').initializeUnorderedBulkOp()
bulkUpdate.find({ _id: doc.insertedId }).updateOne({ $pull: { arr: { _id: 1 } } })
if (bulkUpdate.length > 0) {
 console.log('executing bulk update')
 await bulkUpdate.execute()
}
// await db.collection('test').updateOne({ _id: doc._id }, { $pull: { arr: { _id: 1 } } })
const updatedDoc = await db.collection('test').findOne({ _id: doc._id })
console.log('after bulk update', updatedDoc)
await db.collection('test').deleteOne({ _id: doc._id })

 

Participants:

 Description   

os: ArchLinux 5.15.2

nodeJS: 14.17.4
mongodb: 4.4.3
nodejs mongodb drvier: 4.2.0

Usual updateOne working when call $pull on array fields containing objects, but bulk operation have no effect.



 Comments   
Comment by Edwin Zhou [ 19/Nov/21 ]

Hi ivan.c@taskworld.com,

Thanks for following up! For future issues like this, we'd like to encourage you to start by asking our community for help by posting on the MongoDB Developer Community Forums.

If the discussion there leads you to suspect a bug in the MongoDB server, then we'd want to investigate it as a possible bug here in the SERVER project.

Best,
Edwin

Comment by Ivan Cherviakov [ 19/Nov/21 ]

I made simple mistake here, sorry for bothering, all working correctly.

Generated at Thu Feb 08 05:52:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.