Prevent cli from hanging on failed count

Fixes #909
This commit is contained in:
rijkvanzanten
2020-11-10 13:00:50 -05:00
parent 79c29c0efb
commit 7cc7f300fa

View File

@@ -6,10 +6,14 @@ export default async function count(collection: string) {
process.exit(1);
}
const records = await database(collection).count('*', { as: 'count' });
const count = Number(records[0].count);
try {
const records = await database(collection).count('*', { as: 'count' });
const count = Number(records[0].count);
console.log(count);
database.destroy();
console.log(count);
} catch (err) {
console.error(err);
} finally {
database.destroy();
}
}