當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。