本文整理汇总了TypeScript中utilities/mongodb-util.findAll函数的典型用法代码示例。如果您正苦于以下问题:TypeScript findAll函数的具体用法?TypeScript findAll怎么用?TypeScript findAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了findAll函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
api.get('/all', async (req: Request, res: Response) => {
try {
res.send(await findAll<Product>(DB_PRODUCTS));
} catch (err) {
res.status(409).json(err);
}
});
示例2: Address
return new Promise<CoinbaseLookup>(async (resolve, reject) => {
try {
const allCompleted = await findAll<CoinbaseCharge>(DB_COMPLETED_COINBASE_TRANSACTIONS);
const allProblems = await findAll<CoinbaseCharge>(DB_PROBLEM_COINBASE_CHARGES);
const allPending = await findAll<CoinbaseCharge>(DB_PENDING_COINBASE_CHARGES);
const address = new Address(xemOrTokenAddress).plain();
const filterCompleted = filterChargesByAddress(allCompleted, address);
const filterProblems = filterChargesByAddress(allProblems, address);
const filterPending = filterChargesByAddress(allPending, address);
const results: CoinbaseLookup = {
completed: filterCompleted,
problems: filterProblems,
pending: filterPending
};
resolve(results);
} catch (err) {
reject(err);
}
});
示例3: async
api.get('/tokens-sold', async (req: Request, res: Response) => {
try {
const usdTotals: Array<UsdTotal> = await findAll<UsdTotal>(DB_USD_TOTALS);
if (req.query.currency === 'usd' && usdTotals.length > 0) {
return res.send({amount: precisionRound(usdTotals[0].currentRaised, 2), milestone: usdTotals[0].nextMilestone });
}
res.status(409).json({ message: 'object or parameter not found.'});
} catch (err) {
res.status(409).json(err);
}
});
示例4: async
export const checkPendingTransactions = async () => {
try {
const charges = await findAll<CoinbaseCharge>(DB_PENDING_COINBASE_CHARGES);
if (charges) {
if (charges.length > 0) {
for (const charge of charges) {
fetchCharge(charge);
}
}
}
} catch (err) {}
await sleep(10000);
checkPendingTransactions();
};