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


TypeScript knex.update函数代码示例

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


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

示例1: async

 return async (db: Knex) => {
   await rollbackMarketState(db, log.market, ReportingState.AWAITING_NEXT_WINDOW);
   await db.update({
     universe: log.originalUniverse,
     needsMigration: db.raw("needsMigration + 1"),
     needsDisavowal: db.raw("needsDisavowal + 1"),
   }).into("markets").where("marketId", log.market);
   return db.update({
     disavowed: db.raw("disavowed - 1"),
   }).into("crowdsourcers").where("marketId", log.market);
 };
开发者ID:AugurProject,项目名称:augur_node,代码行数:11,代码来源:market-migrated.ts

示例2: decreaseTokenSupply

export async function decreaseTokenSupply(db: Knex, augur: Augur, token: Address, amount: BigNumber) {
  const oldSupply: SupplyResult|null = await db.first("supply").from("token_supply").where({ token });
  if (amount.isZero()) return;
  if (oldSupply == null) throw new Error(`Could not find supply for token decrease (token: ${token})`);
  const supply = oldSupply.supply.minus(amount);
  return db.update({ supply: supply.toString() }).into("token_supply").where({ token });
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:7,代码来源:decrease-token-supply.ts

示例3: decreaseTokenBalance

export async function decreaseTokenBalance(db: Knex, augur: Augur, token: Address, owner: Address, amount: BigNumber, log: FormattedEventLog) {
  if (isLegacyReputationToken(augur, token)) return;
  const oldBalance: BalanceResult = await db.first("balance").from("balances").where({ token, owner });
  if (amount.isZero()) return;
  if (oldBalance == null) throw new Error(`Could not find balance for token decrease (token: ${token}, owner: ${owner})`);
  const balance = oldBalance.balance.minus(amount);
  await db.update({ balance: balance.toString() }).into("balances").where({ token, owner });
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:8,代码来源:decrease-token-balance.ts

示例4: increaseTokenSupply

export async function increaseTokenSupply(db: Knex, augur: Augur, token: Address, amount: BigNumber) {
  const oldSupply: SupplyResult = await db.first("supply").from("token_supply").where({ token });
  if (oldSupply == null) {
    await db.insert({ token, supply: amount.toString() }).into("token_supply");
  } else {
    const supply = oldSupply.supply.plus(amount);
    await db.update({ supply: supply.toString() }).into("token_supply").where({ token });
  }
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:9,代码来源:increase-token-supply.ts

示例5: increaseTokenBalance

export async function increaseTokenBalance(db: Knex, augur: Augur, token: Address, owner: Address, amount: BigNumber, log: FormattedEventLog) {
  if (isLegacyReputationToken(augur, token)) return;
  const oldBalance: BalanceResult = await db.first("balance").from("balances").where({ token, owner });
  let balance = amount;
  if (oldBalance == null) {
    await db.insert({ owner, token, balance: balance.toString() }).into("balances");
  } else {
    balance = oldBalance.balance.plus(amount);
    await db.update({ balance: balance.toString() }).into("balances").where({ token, owner });
  }
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:11,代码来源:increase-token-balance.ts

示例6: async

 return async (db: Knex) => {
   await db.update({
     needsDisavowal: db.raw("needsDisavowal - 1"),
   }).into("markets").where("marketId", log.market);
   return db.from("crowdsourcers").where("marketId", log.market).update({ disavowed: db.raw("disavowed + 1") });
 };
开发者ID:AugurProject,项目名称:augur_node,代码行数:6,代码来源:market-participants-disavowed.ts


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