typicode / lowdb

Simple and fast JSON database
MIT License
21.35k stars 918 forks source link

Deleting pairs from array #507

Closed kingpin24 closed 2 years ago

kingpin24 commented 2 years ago

Hi,

If I have this 'db' here:

{
  "roles": [
    {
      "memberid": "123456789",
      "roleid": "987654321"
    },
    {
      "memberid": "111111111",
      "roleid": "222222222"
    }
  ],
  "rcount": 1,
  "profiles": [],
  "pcount": 0
}

How can I find and delete an entry {"memberid": "xyz", "roleid": "xyz"} from roles[] with parameter memberid?

EDIT: I have successfully been able to delete it using unset(), but this leaves a null in that index whenever I use it, how can I fix this?