Question

I'm an Italian PouchDb and AngularJS Developer. My json document is:

{
   "_id": "6",
   "_rev": "3-f7283d7683cd6fb15753f494aad1d49f",
   "name": "Ivrea",
   "owners": [
       {
           "owner_id": 1,
           "name": "asdas",
           "address": "asdas",
           "gender": "Uomo",
           "type": "Assente",
           "notes": [
           ]
       },
       {
           "owner_id": 2,
           "name": "balbaba",
           "address": "blabla",
           "gender": "Uomo",
           "type": "Assente",
           "notes": [
           ]
       }
   ]
}

and after an ng-click action, I will delete owner_id: 2 object inside _id: 6 document. In API reference I found only document delete action, but not how to delete object inside document.

Thanks for your reply!!

Alessandro

Was it helpful?

Solution

You just need to put() the main document back in the database after you remove an object from it. :)

db.get('foo').then(function (doc) {
  delete doc.whatever;
  return db.put(doc);
}).catch(function (err) { /* ... */ });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top