feat: provide exports for ghmattimysql

Rather than people weirdly renaming the resource, just provide event
handlers for ghmattimysql exports.
This commit is contained in:
Linden committed 2022-07-28 14:48:23 +10:00
1 parent 1477812b38
commit 613570167c
2 files changed
+20

No files matched your search

+1
View File
@@ -22,6 +22,7 @@ files {
ui_page 'ui/build/index.html'
provide 'mysql-async'
provide 'ghmattimysql'
convar_category 'OxMySQL' {
'Configuration',
+19
View File
@@ -78,6 +78,23 @@ MySQL.prepare = (
MySQL.execute = MySQL.query;
MySQL.fetch = MySQL.query;
function provide(name: string, cb: Function, sync: Function) {
on(`__cfx_export_ghmattimysql_${name}`, (setCb: Function) => setCb(cb));
on(`__cfx_export_ghmattimysql_${name}Sync`, (setCb: Function) => setCb(sync));
}
// provide the "store" and "storeSync" exports, to provide compatibility for ghmattimysql
// these are not actually used to do anything, simply returning the query as-is
provide(
'store',
(query: string, cb: Function) => {
cb(query);
},
(query: string) => {
return query;
}
);
for (const key in MySQL) {
global.exports(key, MySQL[key]);
@@ -98,4 +115,6 @@ for (const key in MySQL) {
global.exports(`${key}_async`, exp);
global.exports(`${key}Sync`, exp);
if (key === 'execute' || key === 'scalar' || key === 'transaction') provide(key, MySQL[key], exp);
}