Files
bun.sh/src/bun.js/api/sql.classes.ts
Ciro Spaciari 477aa56aa4 Ciro/fix onclose refactor (#22556)
### What does this PR do?

### How did you verify your code works?
2025-09-10 16:20:51 -07:00

94 lines
1.9 KiB
TypeScript

import { define } from "../../codegen/class-definitions";
const types = ["PostgresSQL", "MySQL"];
const classes = [];
for (const type of types) {
classes.push(
define({
name: `${type}Connection`,
construct: true,
finalize: true,
configurable: false,
hasPendingActivity: type === "PostgresSQL",
klass: {
// escapeString: {
// fn: "escapeString",
// },
// escapeIdentifier: {
// fn: "escapeIdentifier",
// },
},
JSType: "0b11101110",
proto: {
close: {
fn: "doClose",
},
connected: {
getter: "getConnected",
},
ref: {
fn: "doRef",
},
unref: {
fn: "doUnref",
},
flush: {
fn: "doFlush",
},
queries: {
getter: "getQueries",
this: true,
},
onconnect: {
getter: "getOnConnect",
setter: "setOnConnect",
this: true,
},
onclose: {
getter: "getOnClose",
setter: "setOnClose",
this: true,
},
},
values: ["onconnect", "onclose", "queries"],
}),
);
classes.push(
define({
name: `${type}Query`,
construct: true,
finalize: true,
configurable: false,
JSType: "0b11101110",
klass: {},
proto: {
run: {
fn: "doRun",
length: 2,
},
cancel: {
fn: "doCancel",
length: 0,
},
done: {
fn: "doDone",
length: 0,
},
setMode: {
fn: "setMode",
length: 1,
},
setPendingValue: {
fn: "setPendingValue",
length: 1,
},
},
values: ["pendingValue", "target", "columns", "binding"],
estimatedSize: true,
}),
);
}
export default classes;