[fix] add tx method for client; [todo] add exec on client

This commit is contained in:
Anton Nesterov 2024-08-15 17:56:52 +02:00
parent 9d13824fdf
commit 6670c1f55a
No known key found for this signature in database
GPG key ID: 59121E8AE2851FB5
2 changed files with 7 additions and 3 deletions

View file

@ -113,8 +113,8 @@ export default class Builder<I extends abstract new (...args: any) => any> {
this.methodCalls.set("Delete", []); this.methodCalls.set("Delete", []);
return this; return this;
} }
Insert(data: Record<string, unknown>): Builder<I> { Insert(...data: Record<string, unknown>[]): Builder<I> {
this.methodCalls.set("Insert", [data]); this.methodCalls.set("Insert", data);
return this; return this;
} }
Set(data: Record<string, unknown>): Builder<I> { Set(data: Record<string, unknown>): Builder<I> {
@ -139,6 +139,10 @@ export default class Builder<I extends abstract new (...args: any) => any> {
this.methodCalls.set("DoNothing", []); this.methodCalls.set("DoNothing", []);
return this; return this;
} }
Tx(): Builder<I> {
this.methodCalls.set("Tx", []);
return this;
}
async *Rows<T = InstanceType<I>>(): AsyncGenerator<T> { async *Rows<T = InstanceType<I>>(): AsyncGenerator<T> {
this.formatRequest(); this.formatRequest();
const response = await fetch(this.url, { const response = await fetch(this.url, {

View file

@ -12,7 +12,7 @@ export interface Request {
} }
export const METHODS = export const METHODS =
"In|Find|Select|Fields|Join|Group|Sort|Limit|Offset|Delete|Insert|Set|Update|OnConflict|DoUpdate|DoNothing".split( "In|Find|Select|Fields|Join|Group|Sort|Limit|Offset|Delete|Insert|Set|Update|OnConflict|DoUpdate|DoNothing|Tx".split(
"|", "|",
); );