本文介绍了PouchDb-删除文档中的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是意大利的PouchDb和AngularJS开发人员。
我的json文档是:
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": [
]
}
]
}
,然后按 ng次
操作,我将删除 _id:6
文档中的 owner_id:2
对象。在API参考中,我仅找到文档删除操作,而没有找到如何删除文档中的对象。
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.
感谢您的答复!
亚历山德罗
推荐答案
您只需要 put()
从数据库中删除对象后,将主文档返回数据库。 :)
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) { /* ... */ });
这篇关于PouchDb-删除文档中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!