UNPKG

surrealql

Version:

small SurrealDB JS/TS library to help facilitate the use of SurrealQL

22 lines 683 B
import { $fetch } from "ohmyfetch"; export function create_surrealql(opts = {}) { const headers = {}; if (opts.auth) headers["Authorisation"] = Buffer.from(`${opts.auth.username}:${opts.auth.password}`).toString("base64"); if (opts.namespace) headers["NS"] = opts.namespace; if (opts.database) headers["DB"] = opts.database; const fetch = $fetch.create({ baseURL: opts.url ?? "http://localhost:8000/sql", method: "POST", headers, responseType: "json" }); return async function (query) { return await fetch("", { body: query }); }; } //# sourceMappingURL=index.mjs.map