Skip to content

Repository files navigation

SQL is designed for managing or stream processing data in an RDBMS. This package provides a set of functions to generate SQL commands for creating tables, inserting data, and performing various operations, including text search and matching, on SQL databases (PostgreSQL).

▌ 📦 JSR, 📰 Docs,


import*asxsqlfrom"jsr:@nodef/extra-sql";xsql.tableExists("food");// → SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name='food');xsql.setupTable("food",{code: "TEXT",name: "TEXT"},[{code: "F1",name: "Mango"},{code: "F2",name: "Lychee"}]);// → CREATE TABLE IF NOT EXISTS "food" ("code" TEXT, "name" TEXT);// → INSERT INTO "food" ("code", "name") VALUES// → ($$F1$$, $$Mango$$),// → ($$F2$$, $$Lychee$$);xsql.selectTsquery("columns","total fat");// → SELECT * FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat');xsql.matchTsquery("columns",["total","fat"]);// → SELECT *, '2'::INT AS "matchTsquery" FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat') UNION ALL// → SELECT *, '1'::INT AS "matchTsquery" FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total');

Index

NameDescription
createTableGenerate SQL command for CREATE TABLE.
createIndexGenerate SQL command for CREATE INDEX.
createViewGenerate SQL command for CREATE VIEW.
insertIntoGenerates SQL command for INSERT INTO using an array of values.
setupTableGenerate SQL commands to set up a table (create, insert, index).
tableExistsGenerate SQL command to check if a table exists.
selectTsqueryGenerate SQL command for SELECT with tsquery.
matchTsqueryGenerate SQL query for matching words with tsquery.
insertIntoStreamGenerate SQL command for INSERT INTO using a stream of values.
setupTableIndexGenerate SQL commands for setting up table indexes and views.
createTableDataGenerate SQL command for creating a table with data.
updateDataGenerate SQL command for updating data.
selectDataGenerate SQL command for selecting data.
insertIntoDataGenerate SQL command for inserting data.
deleteDataGenerate SQL command for deleting data.
OPERATORSSet of operators in SQL. {field}
OPERAND_COUNTNumber of operands used with an SQL operator. {field}



ORG

About

Generates SQL commands for creating tables, inserting data, and performing operations like text search and matching in PostgreSQL databases.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Used by

Contributors

Languages