0

I have created a database to store details of people. I have a record like:

   {"Name":"moon","Email":"night","User":"sun","Password":"earth","_id":"kpOBxczJlr2R5S68"}

How do change the password from 'earth' to 'mars'?? How do I use the db.update() in NeDB to make this change??

1 Answers1

0

Doesn't the way explained in the docs work for you? For example:

db.update({ _id: 'kpOBxczJlr2R5S68 }, { password: 'mars' }, {}, (err, num) => {
  // ...
});

What have you tried so far? Did you try the examples from the documentation?

rsp
  • 107,747
  • 29
  • 201
  • 177
  • I want to add Salary and Company field also. So I wrote it like: var id= result._id; result is the object db.update( { id}, { $set: { Salary: Salary,Company: Company} }, {}, function (err, numReplaced) { console.log("replaced---->" + numReplaced); } ); Is there anything wrong in this? – Aarathi .V.B Jul 13 '17 at 14:29
  • @Aarathi.V.B Yes. You're using `{ id }` which is the same as `{ id: id }` and here you should use the key of `_id` as in my example. Did you run that code at all? - On the other hand `{ Salary: Salary, Company: Company }` can be shortened as `{ Salary, Company }` – rsp Jul 13 '17 at 15:54