Skip to content

surrealdb/surrealql.wasm

@surrealdb/wasm

WebAssembly utility functions for SurrealQL.

Importing the module

A few code snippets to showcase various ways of importing the library.

import { SurrealQL, Value } from '@surrealdb/ql-wasm';

Via UNPKG

import { SurrealQL, Value } from 'https://unpkg.com/@surrealdb/ql-wasm/dist/surrealql/index.js';

Example usage

import { SurrealQL, Value } from '@surrealdb/ql-wasm';

// Creating a SurrealQL Value
const value = Value.from_string("{ id: \"person:tobie\" }");
const value = Value.from_json({ id: "person:tobie" });
const value = Value.from_cbor(/* Uint8Array */);

// Formatting a value
value.format();
value.format(true); // Pretty
value.json();
value.json(true); // Pretty

// Converting a value to CBOR, represented as a Uint8Array
value.to_cbor();

// Formatting queries
SurrealQL.format("SELECT * FROM person");

// Validating queries or values
SurrealQL.validate("SELECT * FROM person");
SurrealQL.validate_where("something = true");
SurrealQL.validate_value("[1, 2, 3]");
SurrealQL.validate_thing("person:tobie");
SurrealQL.validate_idiom("person:tobie->likes[WHERE something]");
SurrealQL.validate_subquery("SELECT * FROM person");

// Extracting tables from a kind
SurrealQL.extract_tables_from_kind("record<person>");
// ["person"]
SurrealQL.extract_tables_from_kind("record<a | b | c>");
// ["a", "b", "c"]

About

WebAssembly utility functions for SurrealQL parsing and validation

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •