MongoDB Data object is here, It use mongoose so has Schema, The Schema name is Users :
{
id: abcd1234
level: 1,
user_name: 'Man'
}
I want to make general function that can change database.
function editData(key, value){
Users.findOne({ id : 'abcd1234' }, function(err, user){
// The problem is below line
user.key = value;
user.save(....);
});
}
It didn't work. because user
doesn't has key
schema. I think Node.js think the 'key' to mongodb schema, not a parameter. How can I use key
as a parameter?