2

私はイタリアの PouchDb と AngularJS の開発者です。私のjsonドキュメントは次のとおりです。

{
   "_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": [
           ]
       }
   ]
}

ng-clickアクションの後、ドキュメントowner_id: 2内のオブジェクトを削除します_id: 6。API リファレンスでは、ドキュメントの削除アクションのみが見つかりましたが、ドキュメント内のオブジェクトを削除する方法は見つかりませんでした。

お返事をありがとうございます!!

アレッサンドロ

4

1 に答える 1

1

put()オブジェクトを削除した後、メイン文書をデータベースに戻すだけです。:)

db.get('foo').then(function (doc) {
  delete doc.whatever;
  return db.put(doc);
}).catch(function (err) { /* ... */ });
于 2014-08-01T12:00:12.720 に答える