louischatriot / nedb

The JavaScript Database, for Node.js, nw.js, electron and the browser
MIT License
13.46k stars 1.03k forks source link

Permanently deleting an entry from persistant storage #665

Open soubhikchatterjee opened 3 years ago

soubhikchatterjee commented 3 years ago

I am using nedb in one of my projects. It seems to be matching my needs so far. I see one issue though, when trying to delete a record, instead of deleting the entire record, it does a partial deletion. i.e. it deletes the record and adds $$deleted: true.

{"$$deleted":true,"_id":"5ff56dece70e4d331ca9d724"}

Can the record be deleted permanently?

This is my code:

  db.remove({ name: doc.name }, {}, function (err, numRemoved) {
        // numRemoved = 1
      });
jampy commented 3 years ago

you can manually call compactDatafile(), read https://github.com/louischatriot/nedb#persistence

RickyKongCoder commented 1 year ago

actually I have tried run compactDatafile() in callback of db.remove but still not works. the function has no effect