query

The query static getter in SchemaJS provides a method for executing queries built with the QueryBuilder. It ensures that only queries constructed using the QueryBuilder class can be executed, offering a layer of validation before performing the actual query operation. The method then retrieves the results by calling the internal searchRows function, which queries the specified database and table using the built query.

const query = new QueryBuilder("public", "books")
    .where("author_age", "=", 25)
    .build();

// Execute the query
SchemaJS.query(query).then((rows) => {
    SchemaJS.print(rows);
});

Last updated