Vote count:
0
Because of a weird bug in my code, I have a collection with field names which are stricly numbers (ex: 34344,54675,34356). Now I try to move these fields values to another fields (ex: name,email,etc) but when I run the update command:
db.collection.find({"id_field" : 1996}).forEach(function (elem) {db.collection.update({_id: elem._id},{$set: {name: elem.36536}});});
All I get is an error:
SyntaxError: Unexpected number
How should I handle it? I already tried with elem[36536] instead elem.36536 but without success.
asked 1 min ago
Mongodb field name as numbers - how to use it in updates?
Aucun commentaire:
Enregistrer un commentaire