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