findOneAndUpdate

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 3.1.0
    • Affects Version/s: 3.0.7
    • Component/s: Native
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Hello,

       
      The methode findOneAndUpdate with a empty update field $unset all the field. :
       
      collection.findOneAndUpdate({ _id: new ObjectID(id) }, {}, { upsert: false })
       
      I know that if empty i should prefer use only the findOne method but it seems dangerous to unset all if empty in this method. and i need to use it like this. Expect to do nothing if empty.
       
       
      Dor now i make the trick to protect against the $unset all with : 
      collection.findOneAndUpdate({ _id: new ObjectID(channelId) }, { $setOnInsert:

      { insert: true }

      }, { upsert: false })
       
      Can you update this rules?
       
       

              Assignee:
              Katherine Walker (Inactive)
              Reporter:
              ohrrkan
              None
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: