문제

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