本文整理匯總了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);
});
});