@tsnobip Thank for you reply, I’m trying to solve this problem with other way these days, but it doesn’t work well
First I patch the code (compile to PostgresqlPatch.js)
%%raw(`
import Postgres from "postgres"
export default myPostgres;
function myPostgres(a, b) {
var sql = Postgres(a, b);
Object.assign(sql, {safeSql: sql})
return sql;
}
`)
Then bind the path code use the object function
type t
@module("./PostgresqlPatch.js") external make: (~url: string, ~config: config=?) => t = "default"
@taggedTemplate @send
external safeSql: (t, array<string>, array<'sqlParam>) => promise<result<'data>> = "safeSql"
Then call object function:
let abc = "name"
let result: Postgresql.result<userInfo> = await sql->Postgresql.safeSql`select name, sigup_date from user_tbl where name=${ abc }`
output:
var result = await sql.safeSql([
"select name, sigup_date from user_tbl where name=",
""
], "name");
Is it possible to consider ways to support object functions in the future?
Thanks.