本文整理汇总了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);
};
示例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 });
}
示例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 });
}
示例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 });
}
}
示例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 });
}
}
示例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") });
};