import { Surreal } from "surrealdb@1";
/**
* @param query The query string.
* @param variables The variables used in the query.
*/
type Surrealdb = {
url: string;
token: string;
};
export async function main(
auth: Surrealdb,
namespace: string,
database: string,
query: string,
variables?: Record<string, unknown>,
) {
const client = new Surreal();
await client.connect(auth.url);
await client.authenticate(auth.token);
await client.use({ namespace, database });
const result = await client.query(query, variables);
await client.close();
return result;
}
Submitted by hugo989 14 days ago