NodeJS and MongoDB FindAndModify() need remove or update

前端 未结 4 1415
抹茶落季
抹茶落季 2020-12-03 11:32

im trying to do a findAndModifiy in mongodb with nodejS, This is my code:

var nextBill = function (db, success, log) {
    var collection = db.collection(\'         


        
4条回答
  •  误落风尘
    2020-12-03 11:35

    Try this It worked for me in nodejs

    users.findAndModify(
               { "_id": userid,"password":pwd},
               [['_id', 'asc']],
               { "$set":{"password":npwd}},
               {"upsert":false}
            ,function(err,result){
            //enter code here
    
        })
    

提交回复
热议问题