当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript pg-promise.as类代码示例

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


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

示例1: createBulkAccountsSQL

 public static createBulkAccountsSQL(addresses: string[]) {
   if (!addresses) {
     return '';
   }
   addresses = addresses.filter((addr) => addr);
   if (addresses.length === 0) {
     return '';
   }
   return pgp.as.format(`
   INSERT into mem_accounts(address)
   SELECT address from (VALUES $1:raw ) i (address)
   LEFT JOIN mem_accounts m1 USING(address)
   WHERE m1.address IS NULL`,
     addresses.map((address) => pgp.as.format('($1)', address)).join(', '));
 }
开发者ID:RiseVision,项目名称:rise-node,代码行数:15,代码来源:AccountsModel.ts

示例2: searchDelegate

  public static searchDelegate(q: string, limit: number, orderBy: string, orderHow: 'ASC' | 'DESC' = 'ASC') {
    if (['ASC', 'DESC'].indexOf(orderHow.toLocaleUpperCase()) === -1) {
      throw new Error('Invalid ordering mechanism')
    }

    return pgp.as.format(`
    WITH
      supply AS (SELECT calcSupply((SELECT height FROM blocks ORDER BY height DESC LIMIT 1))::numeric),
      delegates AS (SELECT row_number() OVER (ORDER BY vote DESC, m."publicKey" ASC)::int AS rank,
        m.username,
        m.address,
        m.cmb,
        ENCODE(m."publicKey", 'hex') AS "publicKey",
        m.vote,
        m."votesWeight",
        m.producedblocks,
        m.missedblocks,
        ROUND(vote / (SELECT * FROM supply) * 100, 2)::float AS approval,
        (CASE WHEN producedblocks + missedblocks = 0 THEN 0.00 ELSE
        ROUND(100 - (missedblocks::numeric / (producedblocks + missedblocks) * 100), 2)
        END)::float AS productivity,
        COALESCE(v.voters_cnt, 0) AS voters_cnt,
        t.timestamp AS register_timestamp
        FROM delegates d
        LEFT JOIN mem_accounts m ON d.username = m.username
        LEFT JOIN trs t ON d."transactionId" = t.id
        LEFT JOIN (SELECT "dependentId", COUNT(1)::int AS voters_cnt from mem_accounts2delegates GROUP BY "dependentId") v ON v."dependentId" = ENCODE(m."publicKey", 'hex')
        WHERE m."isDelegate" = 1
        ORDER BY \${orderBy:name} \${orderHow:raw})
      SELECT * FROM delegates WHERE username LIKE \${q} LIMIT \${limit}
    `, {
      q: `%${q}%`,
      limit,
      orderBy,
      orderHow
    });

  }
开发者ID:RiseVision,项目名称:rise-node,代码行数:38,代码来源:AccountsModel.ts

示例3:

 addresses.map((address) => pgp.as.format('($1)', address)).join(', '));
开发者ID:RiseVision,项目名称:rise-node,代码行数:1,代码来源:AccountsModel.ts

示例4: pgPromise

/// <reference path='../../typescript/pg-promise' />

import * as pgPromise from 'pg-promise';

var value1 = pgPromise.as.array([]);
var value2 = pgPromise.as.array(()=>[]);

var pgp:pgPromise.IMain = pgPromise();

var value3 = pgp.as.array([]);
var value4 = pgp.as.array(()=>[]);
var value5 = pgp.as.format('hello', []);
var value6 = pgp.as.format(new pgPromise.QueryFile(''));
开发者ID:andrewharvey,项目名称:pg-promise,代码行数:13,代码来源:formatting.ts


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