by adam186 ยท 4/10/2023
1
import Surreal from "https://deno.land/x/[email protected]/mod.ts";
2
3
/**
4
* @param query The query string.
5
* @param variables The variables used in the query.
6
*/
7
type Surrealdb = {
8
url: string;
9
token: string;
10
};
11
export async function main(
12
auth: Surrealdb,
13
namespace: string,
14
database: string,
15
query: string,
16
variables?: Record<string, unknown>,
17
) {
18
const client = new Surreal(auth.url, auth.token);
19
await client.use(namespace, database);
20
const result = await client.query(query, variables);
21
client.close();
22
return result;
23
}
24