mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 06:28:54 +00:00
fix: Return null if query failed, show callback warning only in debug
This commit is contained in:
1 file changed
+3
-2
+3
-2
@@ -1,5 +1,6 @@
|
||||
import { pool } from './pool';
|
||||
import { execute } from './execute';
|
||||
import { debug } from './config';
|
||||
|
||||
setImmediate(async () => {
|
||||
try {
|
||||
@@ -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`);
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user