[SERVER-21153] Array Field Limitations and Positional Update Created: 27/Oct/15  Updated: 27/Oct/15  Resolved: 27/Oct/15

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

Type: Question Priority: Critical - P2
Reporter: efkan turen Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

node-mongodb-native v2.0.42 is used on Node.js on Windows 10


Participants:

 Description   

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 */
        }



 Comments   
Comment by Ramon Fernandez Marina [ 27/Oct/15 ]

Thanks for your report efkan. As you point out this is an existing limitation of the positional operator, so you may want to explore other options, perhaps using aggregation.

Please note that the SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag, where your question will reach a larger audience. A question like this involving more discussion would be best posted on the mongodb-user group. See also our Technical Support page for additional support resources.

Regards,
Ramón.

Generated at Thu Feb 08 03:56:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.