I need to keep only one document in my nedb.
So I make db.update({ active: true }, data, { upsert: true }, function (err, savedNum) { ... })
where data is { active: true, name: 'name', token: '1234567890' }
It saves doc and keep it only one yet on a first time.
But second time while updating (data is almost the same, only token is different), it doesn’t replace existing document – it adds another one..
On the third time it stops to add new ones, but replace one of existing ones..
@voronianski this is not a bug. The datafile is append only but gets autocompacted upon every reload. If you look closely, you’ll see that the documents in your file habe the same _id, meaning they re in fact the different states of the same doc, the last one being the latest one
When checking the contents of a db, never look at the file, always do a db.find()