本文整理汇总了TypeScript中pouchdb.allDocs函数的典型用法代码示例。如果您正苦于以下问题:TypeScript allDocs函数的具体用法?TypeScript allDocs怎么用?TypeScript allDocs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了allDocs函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getAllAsync
getAllAsync():Promise<any[]> {
return db.allDocs({
include_docs: true,
startkey: this.name + "--",
endkey: this.name + "--\uffff"
}).then((resp:any) => resp.rows.map((e:any) => e.doc))
}
示例2: testAllDocs
function testAllDocs() {
const db = new PouchDB<{ foo: number }>();
db.allDocs().then(({ offset, total_rows, rows }) => {
isNumber(offset);
isNumber(total_rows);
rows.forEach(({ id, key, value, doc }) => {
isString(id);
isString(key);
isString(value.rev);
// check document property
isNumber(doc.foo);
});
});
db.allDocs({ startkey: "a", endkey: "b" });
db.allDocs({ startkey: "a", endkey: "b", inclusive_end: true });
db.allDocs({ keys: ["a", "b", "c" ]});
db.allDocs({ key: "a" });
db.allDocs({
attachments: true,
binary: true,
conflicts: true,
descending: true,
include_docs: true,
limit: 5,
skip: 1
});
}
示例3: Promise
return new Promise(resolve =>{
this.db.allDocs({
include_docs : true,
limit: 20,
descending: true
}).then((recieved)=>{
this.data = [];
let docs = recieved.rows.map((row) => {
this.data.push(row.doc);
});
this.data.reverse();//get latest
resolve(this.data);
this.db.changes({live : true , since : 'now', include_docs:true}).on(
'change',(change)=>{
this.handleChange(change);
});
}).catch((error)=>{
console.log(error);
});
});