Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

Commit 6135701

Browse files
committed
feat: provide exports for ghmattimysql
Rather than people weirdly renaming the resource, just provide event handlers for ghmattimysql exports.
1 parent 1477812 commit 6135701

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

fxmanifest.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ files {
2222
ui_page 'ui/build/index.html'
2323

2424
provide 'mysql-async'
25+
provide 'ghmattimysql'
2526

2627
convar_category 'OxMySQL' {
2728
'Configuration',

src/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ MySQL.prepare = (
7878
MySQL.execute = MySQL.query;
7979
MySQL.fetch = MySQL.query;
8080

81+
function provide(name: string, cb: Function, sync: Function) {
82+
on(`__cfx_export_ghmattimysql_${name}`, (setCb: Function) => setCb(cb));
83+
on(`__cfx_export_ghmattimysql_${name}Sync`, (setCb: Function) => setCb(sync));
84+
}
85+
86+
// provide the "store" and "storeSync" exports, to provide compatibility for ghmattimysql
87+
// these are not actually used to do anything, simply returning the query as-is
88+
provide(
89+
'store',
90+
(query: string, cb: Function) => {
91+
cb(query);
92+
},
93+
(query: string) => {
94+
return query;
95+
}
96+
);
97+
8198
for (const key in MySQL) {
8299
global.exports(key, MySQL[key]);
83100

@@ -98,4 +115,6 @@ for (const key in MySQL) {
98115

99116
global.exports(`${key}_async`, exp);
100117
global.exports(`${key}Sync`, exp);
118+
119+
if (key === 'execute' || key === 'scalar' || key === 'transaction') provide(key, MySQL[key], exp);
101120
}

0 commit comments

Comments
 (0)