mongodb The name of the modified field can not start with $

advertisements

I manage my db with mongodb using node.js

In server.js, this code evoke error

TB_LolCombinationOfChampion.update({},{ $set: { $set: { win: 23445123123 }}},{multi: true},function (err, raw) {
                        if (err) console.log(err);
                        console.log('The raw response from Mongo was ', raw);
                        });

I get this error

{ [MongoError: Modified field name may not start with $]
name: 'MongoError',
err: 'Modified field name may not start with $',
code: 15896,
n: 0,
connectionId: 601,
ok: 1 }
The raw response from Mongo was null

Why this error evoke and how I avoid this error?


The problem is you repeated $set twice Instead of

{ $set: { $set: { win: 23445123123 }}}

Do

{ $set: { win: 23445123123 }}