typicode / lowdb

Simple and fast JSON database
MIT License
21.49k stars 923 forks source link

How to remove my matching multiple object fields #457

Closed SwapnilSoni1999 closed 3 years ago

SwapnilSoni1999 commented 3 years ago

I have following data

"tracking": [
        {
          "pincode": "380061",
          "age_group": 18
        },
        {
          "pincode": "380061",
          "age_group": 45
        }
      ]
    }

I want to delete by matching pincode 380061 and age_group 45 and keep the one with age_group 18

I've tried

db.get('tracking').remove({ pincode: 380061, age_group: 45 }).write()

but it is not working

Valexr commented 3 years ago

matching just by one obj props, maybe?

db.get('tracking').remove({ age_group: 45 }).write() 
SwapnilSoni1999 commented 3 years ago

matching just by one obj props, maybe?

db.get('tracking').remove({ age_group: 45 }).write() 

Thanks but I've solved issue by giving each entry a nanoid