mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 14:38:50 +00:00
feat: Add an export to call prepared statements (#54)
* feat: Add an export to call prepared queries - Utilises pool.execute (rather than query) to actually prepare parameters through mysql. This is intended for appropriately built queries utilising placeholders and parameters, and should only be used on frequently repeated queries. * refactor(prepare): Clean up results and add total execution time * feat(prepare): Send scalar response for a single value * fix(prepare): Check if result exists before getting keys
This commit is contained in:
1 parent
1d0a5bcfd9
commit
2a8f4b1ea9
3 files changed
+102
-28
No files matched your search
+11
-1
@@ -1,5 +1,5 @@
|
||||
import { pool } from './pool';
|
||||
import { execute } from './execute';
|
||||
import { execute, preparedStatement } from './execute';
|
||||
import { transaction } from './transaction';
|
||||
import { debug, isolationLevel } from './config';
|
||||
|
||||
@@ -55,7 +55,17 @@ global.exports('transaction', (queries, parameters, cb, resource = GetInvokingRe
|
||||
});
|
||||
});
|
||||
|
||||
global.exports('prepared', (query, parameters, cb, resource = GetInvokingResource()) => {
|
||||
preparedStatement(query, parameters, resource).then((result) =>
|
||||
safeCallback(cb || parameters, result, resource, query))
|
||||
});
|
||||
|
||||
if (!GetResourceMetadata(GetCurrentResourceName(), 'server_script', 1)) {
|
||||
global.exports('preparedSync', async (query, parameters) => {
|
||||
const result = await preparedStatement(query, parameters, GetInvokingResource());
|
||||
return result;
|
||||
});
|
||||
|
||||
global.exports('executeSync', async (query, parameters) => {
|
||||
const result = await execute(query, parameters, GetInvokingResource());
|
||||
return result;
|
||||
|
||||
Reference in new issue
Block a user