D
D
Dvorak2016-06-25 03:07:34
MongoDB
Dvorak, 2016-06-25 03:07:34

How to partially modify an object in MongoDB?

Hello. I am using node-mongodb-native.
After the following code, all fields are completely erased from the selected object and only time: "20:00" remains

let users = db.collection('users');
users.update({telegramId:4}, {time:'20:00'}, function(err) {
      if (err) throw err;
});

What method to call so that the time field changes and the rest remain unchanged?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav, 2016-06-25
@allishappy

{$set: {time:'20:00'}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question