本文整理匯總了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") });
};