zql-utils
v0.1.0
Published
Utility functions for ZQL
Readme
zql-utils
Utility functions for ZQL
Importing the module
A few code snippets to showcase various ways of importing the library.
import { ZQL, Value } from "zql-utils/v1";
import { ZQL, Value } from "zql-utils/v2";Example usage
import { ZQL, Value } from "zql-utils/v1";
// Creating a ZQL 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();
// Parsing queries
ZQL.parse("SELECT * FROM person");
// Formatting queries
ZQL.format("SELECT * FROM person");
// Validating queries or values
ZQL.validate("SELECT * FROM person");
ZQL.validate_where("something = true");
ZQL.validate_value("[1, 2, 3]");
ZQL.validate_thing("person:tobie");
ZQL.validate_idiom("person:tobie->likes[WHERE something]");
ZQL.validate_subquery("SELECT * FROM person");