edgedb-js
edgedb-js copied to clipboard
Positional arguments in queries generator
When creating query like this:
insert OtpPhoneRequest {
phone := <str>$0,
otp := <int32>$1,
sentAt := <datetime>$2
};
Generated query will be:
export type InsertOtpRequestArgs = {
"0": string;
"1": number;
"2": Date;
};
export type InsertOtpRequestReturns = {
"id": string;
};
export async function insertOtpRequest(client: Executor, args: InsertOtpRequestArgs): Promise<InsertOtpRequestReturns> {
return client.queryRequiredSingle(`\
insert OtpPhoneRequest {
phone := <str>$0,
otp := <int32>$1,
sentAt := <datetime>$2
};`, args);
But I execpect it should be like this:
export type InsertOtpRequestArgs = [string, number, Date]
export type InsertOtpRequestReturns = {
id: string
}
export async function insertOtpRequest(
client: Executor,
...args: InsertOtpRequestArgs
): Promise<InsertOtpRequestReturns> {
return client.queryRequiredSingle(
`\
insert OtpPhoneRequest {
phone := <str>$0,
otp := <int32>$1,
sentAt := <datetime>$2
};`,
...args
)
}