Skip to main content

Building sql

The idea taken from sql-template-tag, big thanks to the author! It uses the power of ES2015 tagged template string for preparing SQL statements.

When you build queries, you need to follow one rule to keep your queries reactive:

info

Always use sql.table('tableName') or sql.table`tableName` when you reference to the table in the query. It allows to keep your queries reactive.

import { sql } from "@kikko-land/kikko";

const booksTables = sql.table`books`;
sql`SELECT * FROM ${booksTables}`;
sql`INSERT INTO ${booksTables} VALUES (1, 2, 3)`;

Usage examples