Skip to content

Commit

Permalink
fix: Return null if query failed, show callback warning only in debug
Browse files Browse the repository at this point in the history
  • Loading branch information
dunak-debug committed Sep 20, 2021
1 parent a0573c8 commit 06b1061
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { pool } from './pool';
import { execute } from './execute';
import { debug } from './config';

setImmediate(async () => {
try {
Expand All @@ -12,8 +13,8 @@ setImmediate(async () => {

const safeCallback = (callback, result, resource, query) => {
if (typeof callback === 'function')
return callback(result || false);
else if (callback)
return callback(result);
else if (debug)
return console.log(`^3[WARNING] ${resource} executed a query, but no callback function was defined!\n ^3 ${query}^0`);
};

Expand Down

0 comments on commit 06b1061

Please sign in to comment.