本文整理汇总了TypeScript中dexie.Promise.all方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Promise.all方法的具体用法?TypeScript Promise.all怎么用?TypeScript Promise.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dexie.Promise
的用法示例。
在下文中一共展示了Promise.all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: relationValueMap
private async relationValueMap(joinQueryIds: Relation<number[]>): Promise<Relation<Map<number, string>>> {
let accounts = [] as DexiePromise<Entity[]>[];
let categories = [] as DexiePromise<Entity[]>[];
let subcategories = [] as DexiePromise<Entity[]>[];
let payeePayers = [] as DexiePromise<Entity[]>[];
let tags = [] as DexiePromise<Entity[]>[];
const tables = [
this.db.accounts,
this.db.categories,
this.db.subcategories,
this.db.payeePayers,
this.db.tags
];
await this.db.transaction('r', tables, () => {
joinQueryIds.accounts .forEach((id) => accounts .push(this.db.accounts .where('id').equals(id).toArray()));
joinQueryIds.categories .forEach((id) => categories .push(this.db.categories .where('id').equals(id).toArray()));
joinQueryIds.subcategories.forEach((id) => subcategories.push(this.db.subcategories.where('id').equals(id).toArray()));
joinQueryIds.payeePayers .forEach((id) => payeePayers .push(this.db.payeePayers .where('id').equals(id).toArray()));
joinQueryIds.tags .forEach((id) => tags .push(this.db.tags .where('id').equals(id).toArray()));
});
const allResolved = {
accounts : lodash.flattenDeep<Entity>(await Dexie.Promise.all(accounts)),
categories : lodash.flattenDeep<Entity>(await Dexie.Promise.all(categories)),
subcategories: lodash.flattenDeep<Entity>(await Dexie.Promise.all(subcategories)),
payeePayers : lodash.flattenDeep<Entity>(await Dexie.Promise.all(payeePayers)),
tags : lodash.flattenDeep<Entity>(await Dexie.Promise.all(tags)),
} as Relation<Entity[]>;
const _allMap = {
accounts: new Map(),
categories: new Map(),
subcategories: new Map(),
payeePayers: new Map(),
tags: new Map()
} as Relation<Map<number, string>>;
allResolved.accounts .map((item) => _allMap.accounts .set(item.id, item.name));
allResolved.categories .map((item) => _allMap.categories .set(item.id, item.name));
allResolved.subcategories.map((item) => _allMap.subcategories.set(item.id, item.name));
allResolved.payeePayers .map((item) => _allMap.payeePayers .set(item.id, item.name));
allResolved.tags .map((item) => _allMap.tags .set(item.id, item.name));
return _allMap;
}
示例2: getUrlsAndStatuses
// With async/await
async function getUrlsAndStatuses() {
let urls = await db.syncable.list();
let statuses = await Dexie.Promise.all(urls.map(url => db.syncable.getStatus(url)));
}