我已经创建了一个服务和一个控制器,但教程我不明白如何创建添加/编辑和删除功能我如何去做。或者我在哪里可以找到解释它的角袋。
.service('pouchdb', [
function() {
return new PouchDB('myApp');
}
]);

.controller('pouchDB', function($scope,pouchdb) {
var dbLocal = new PouchDB('LimaT');
var dbRemote = new PouchDB('http://localhost:5984/LimaT');
//add
//edit
//delete
})

答案 0 :(得分:-1)
//添加
var doc = {
"_id": "mittens",
"name": "Mittens",
"occupation": "kitten",
"age": 3,
"hobbies": [
"playing with balls of yarn",
"chasing laser pointers",
"lookin' hella cute"
]
};
db.put(doc);
//编辑
// fetch mittens
db.get('mittens').then(function (doc) {
// update their age
doc.age = 4;
// put them back
return db.put(doc);
}).then(function () {
// fetch mittens again
return db.get('mittens');
}).then(function (doc) {
console.log(doc);
});
取自https://pouchdb.com/guides/documents.html
//删除
db.get('mittens').then(function (doc) {
return db.remove(doc);
});