• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript dexie.Promise类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中dexie.Promise的典型用法代码示例。如果您正苦于以下问题:TypeScript Promise类的具体用法?TypeScript Promise怎么用?TypeScript Promise使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Promise类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: storeHashtagsInTweets

    storeHashtagsInTweets(jsons: Twitter.Status[]) {
        const entries = [] as HashtagsScheme[];
        const push = Array.prototype.push;

        for (const j of jsons) {
            if (!j.entities || !j.entities.hashtags) {
                continue;
            }

            const hashtags = j.entities.hashtags
                .map(h => ({
                    text: h.text,
                    timestamp: Date.now(),
                }));

            push.apply(entries, hashtags);
        }

        if (entries.length === 0) {
            return Dexie.Promise.resolve<void>();
        }

        return this.table.bulkPut(entries)
            .catch((e: Error) => {
                log.error('Error on storing hashtags in tweets:', e, entries);
                throw e;
            });
    }
开发者ID:DevenLu,项目名称:YourFukurou,代码行数:28,代码来源:hashtags.ts


示例2: 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;
  }
开发者ID:armorik83,项目名称:reveal-wealth,代码行数:45,代码来源:money-transaction-repository.service.ts


示例3: 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)));
}
开发者ID:lincolon,项目名称:Dexie.js,代码行数:5,代码来源:test-typings.ts



注:本文中的dexie.Promise类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript dgeni.generate函数代码示例发布时间:2022-05-25
下一篇:
TypeScript dexie.ignoreTransaction函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap