-
Type: Question
-
Resolution: Done
-
Priority: Critical - P2
-
None
-
Affects Version/s: 3.0.7
-
Component/s: Querying
-
Labels:None
-
Environment:node-mongodb-native v2.0.42 is used on Node.js on Windows 10
I've been trying to do important update operations using two-phase commit method. Unfortunately, the field that will be updated in an array. But the same document have to has a pendingTransactions field to store the current transactions. And MongoDB doesn't support positional update
if two array fields are in the query document.
Is there any chance to solve this situation?
Other Additional informations and 'Correct Results' When Two Array Fields Are In The Query
Actually I used a second array in query document without knowing the problem. It works stable. When testing, encountered with the problem at another update operation. So, the first query response correctly every time.
There is a documentation is related array field limitation.
https://docs.mongodb.org/manual/reference/operator/projection/positional/#array-field-limitation
the stable part is like the below [javascript]. With $ne operator it works correct;
var filter = { _id: customer_id, invoices: { $elemMatch: { 'year': 2015, 'month': 8 } }, pendingTransactions: { $ne: transaction_id } } Customers.findOne(filter, { 'invoices.$' }, function(err, customer){ /* Positional operator $ works correct */ }
the unstable part is like the below. ;
var filter = { _id: customer_id, invoices: { $elemMatch: { 'year': 2015, 'month': 8 } }, pendingTransactions: transaction_id } Customers.findOne(filter, { 'invoices.$' }, function(err, customer){ /* Positional operator $ doesn't work correct */ }