[英]Get data from pouchdb
I have successfully put the information into PouchDB, but how can I retrieve the data and show in HTML using AngularJS? 我已经成功地将信息放入PouchDB中,但是如何使用AngularJS检索数据并以HTML显示呢?
var db = new PouchDB('infoDB');
function getData(){
$.getJSON('test.json', function(data) {
var row = data[0].Row;
var info = [];
db.destroy().then(function () {
return new PouchDB('infoDB');
}).then(function(db){
for (var i = 0; i < row.length; i++) {
var info = {
_id: row[i].id,
name: row[i].name,
email: row[i].email,
age: row[i].age
}
db.put(info).then(function(result){
console.log("Everything is ok!");
}).catch(function(err){
console.log('Oh No!');
console.log(err);
});
}
});
});
}
getData();
look for fetching documents from your pouchdb database. 寻找从您的pouchdb数据库中获取文档。
on their website they briefly explain: https://pouchdb.com/api.html#fetch_document 他们在他们的网站上简要说明: https : //pouchdb.com/api.html#fetch_document
to fetch a specific document, look into the find plugin: https://nolanlawson.github.io/pouchdb-find/ it's easy to use and also works with Couch 2.0. 要获取特定文档,请查看find插件: https : //nolanlawson.github.io/pouchdb-find/,它易于使用,还可以与Couch 2.0一起使用。
I'm not able to help you with angular i'm afraid. 恐怕我无法为您提供帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.