Skip to content
This is an experimental feature and the API is subject to frequent changes.

Inline Queries

Inline queries are functions that allow you to execute single, ad-hoc custom queries without needing to create an instance of the Surreal class. The usage is almost identical to the .query() method. Note that JsonFormatter is used by default.

Import

import { query } from "@tai-kun/surrealdb";

Example

import { query, rpc } from "@tai-kun/surrealdb";
const token = await rpc("http://127.0.0.1:8000", "signin", {
params: [{
user: "root",
pass: "root",
}],
});
const results = await query("http://127.0.0.1:8000", "RETURN 42", {}, {
token,
namespace: "test",
database: "test",
});