سؤال

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

هل كانت مفيدة؟

المحلول

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) { /* ... */ });
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top