method updateOne does't work while the fillter include _id field

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Minor - P4
    • None
    • Affects Version/s: 2.0.47
    • Component/s: MongoDB 3.2
    • Environment:
      os: OS X 10.11.4
      node: 4.4.2
      mongo: 3.2.4
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      actually the module version is 2.0.49,but the selector has no option for it......

      when I use updateOne like this:
      var ObjectID = require('mongodb').ObjectID;
      formDao.updateOne(

      {id: ObjectID(postData.id)}

      , {$set: postData}, function (err, reply)

      { cb(err, reply); }

      );

      throw err below:
      { [MongoError: After applying the update to the document {_id: ObjectId('574fe4f70ee6c41917c4dfeb') , ...}, the (immutable) field '_id' was found to have been altered to _id: "574fe4f70ee6c41917c4dfeb"] name: 'MongoError', message: 'After applying the update to the document {_id: ObjectId(\'574fe4f70ee6c41917c4dfeb\') , ...}, the (immutable) field \'_id\' was found to have been altered to _id: "574fe4f70ee6c41917c4dfeb"', driver: true, index: 0, code: 66, errmsg: 'After applying the update to the document {_id: ObjectId(\'574fe4f70ee6c41917c4dfeb\') , ...}, the (immutable) field \'_id\' was found to have been altered to _id: "574fe4f70ee6c41917c4dfeb"' }

      but I try it on command line console:
      db.form.update({_id:ObjectId('574fe4f70ee6c41917c4dfeb')},{$set:{_class:'mmm'}});

      it works!

      you konw what I mean,man,please resolve it, I almost confused with it a half day ~~~(>_<)~~~

            Assignee:
            Christian Amor Kvalheim
            Reporter:
            zhongzhengkai
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: