nedbhq / nedb-core

The JavaScript Database, for Node.js, nw.js, electron and the browser
MIT License
79 stars 9 forks source link

Permanently deleting an entry from persistant storage #9

Closed soubhikchatterjee closed 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
      });
JamesMGreene commented 3 years ago

This is intentional if you read through the documentation: https://github.com/nedbhq/nedb-core#persistence

These records will be cleaned up the next time the database compacts (typically by running auto-compaction).