Skip to content

Release v0.11.0

Compare
Choose a tag to compare
@kearfy kearfy released this 01 Nov 10:17
· 108 commits to main since this release
1ce3f75

Overview

Simplified .query() method

To further align our JS landscape, the current .query() method is renamed to .query_raw(), and a new and simplified .query() method is introduced. This new method either throws an error or gives back an array of response values.

await db.query<boolean, number>(`true; 123`);
// [true, 123]
// This would previously be an array with query response objects, containing the result.

await db.query(`THROW "some error"`);
// Throws: "An error occurred: some error"

Tagged template literals

  • We now expose a PreparedQuery class which can be passed to the .query() and .query_raw() methods.
  • We now expose a surrealql (and surql as a shortcut) function which can be used as a tagged template literal.
const name = "John Doe";
const age = 44;

// With PreparedQuery
const query = new PreparedQuery(
	/* surql */`RETURN $name; RETURN $age`,
	{ name, age }
);

const prepared = await db.query(query);

// With a tagged template literal
const templated = await db.query(
	surrealql`RETURN ${name}; RETURN ${age}`
);

What's Changed

New Contributors

Full Changelog: v0.10.1...v0.11.0