Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-21153

Array Field Limitations and Positional Update

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Done
    • Icon: Critical - P2 Critical - P2
    • None
    • 3.0.7
    • Querying
    • None
    • node-mongodb-native v2.0.42 is used on Node.js on Windows 10

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

      Attachments

        Activity

          People

            Unassigned Unassigned
            efkan efkan turen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: