Skip to content
This is an experimental feature and the API may change frequently.

Inline Queries

Inline queries allow you to execute one-off custom queries without creating an instance of the Surreal class. Usage is very similar to the .query() method; however, 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",
});