Skip to content

Commit ae88dd5

Browse files
committed
add check for empty result set
1 parent 7ead70a commit ae88dd5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mongo-csv.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ const projection = config.projection || {};
3939
const document = await cursor.next();
4040
documents.push(document);
4141
}
42+
if (documents.length === 0) {
43+
console.error('0 documents were found, aborting');
44+
process.exit(1);
45+
}
4246
fs.writeFileSync(outputFilePath, parse(documents));
4347
} catch (err) {
4448
console.log(err.stack);

0 commit comments

Comments
 (0)