https://github.com/nodef/extra-sql
Generates SQL commands for creating tables, inserting data, and performing operations like text search and matching in PostgreSQL databases.
https://github.com/nodef/extra-sql
create create-index create-table create-table-data create-view delete-data exists extra index insert insert-into into match select setup setup-table sql table tsquery view
Last synced: 5 months ago
JSON representation
Generates SQL commands for creating tables, inserting data, and performing operations like text search and matching in PostgreSQL databases.
- Host: GitHub
- URL: https://github.com/nodef/extra-sql
- Owner: nodef
- License: mit
- Created: 2018-05-23T10:20:59.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2025-04-16T12:06:22.000Z (8 months ago)
- Last Synced: 2025-06-19T16:06:47.470Z (6 months ago)
- Topics: create, create-index, create-table, create-table-data, create-view, delete-data, exists, extra, index, insert, insert-into, into, match, select, setup, setup-table, sql, table, tsquery, view
- Language: TypeScript
- Homepage: https://jsr.io/@nodef/extra-sql
- Size: 114 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[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](https://jsr.io/@nodef/extra-sql),
📰 [Docs](https://jsr.io/@nodef/extra-sql/doc),
```javascript
import * as xsql from "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
| Name | Description |
| ---- | ------ |
| [createTable] | Generate SQL command for CREATE TABLE. |
| [createIndex] | Generate SQL command for CREATE INDEX. |
| [createView] | Generate SQL command for CREATE VIEW. |
| [insertInto] | Generates SQL command for INSERT INTO using an array of values. |
| [setupTable] | Generate SQL commands to set up a table (create, insert, index). |
| [tableExists] | Generate SQL command to check if a table exists. |
| [selectTsquery] | Generate SQL command for SELECT with tsquery. |
| [matchTsquery] | Generate SQL query for matching words with tsquery. |
| [insertIntoStream] | Generate SQL command for INSERT INTO using a stream of values. |
| [setupTableIndex] | Generate SQL commands for setting up table indexes and views. |
| [createTableData] | Generate SQL command for creating a table with data. |
| [updateData] | Generate SQL command for updating data. |
| [selectData] | Generate SQL command for selecting data. |
| [insertIntoData] | Generate SQL command for inserting data. |
| [deleteData] | Generate SQL command for deleting data. |
| [OPERATORS] | Set of operators in SQL. {field} |
| [OPERAND_COUNT] | Number of operands used with an SQL operator. {field} |
[](https://wolfram77.github.io)
[](https://nodef.github.io)

[SQL]: https://en.wikipedia.org/wiki/SQL
[createTable]: https://jsr.io/@nodef/extra-sql/doc/~/createTable
[createIndex]: https://jsr.io/@nodef/extra-sql/doc/~/createIndex
[createView]: https://jsr.io/@nodef/extra-sql/doc/~/createView
[insertInto]: https://jsr.io/@nodef/extra-sql/doc/~/insertInto
[setupTable]: https://jsr.io/@nodef/extra-sql/doc/~/setupTable
[tableExists]: https://jsr.io/@nodef/extra-sql/doc/~/tableExists
[selectTsquery]: https://jsr.io/@nodef/extra-sql/doc/~/selectTsquery
[matchTsquery]: https://jsr.io/@nodef/extra-sql/doc/~/matchTsquery
[OPERATORS]: https://jsr.io/@nodef/extra-sql/doc/~/OPERATORS
[OPERAND_COUNT]: https://jsr.io/@nodef/extra-sql/doc/~/OPERAND_COUNT
[insertIntoStream]: https://jsr.io/@nodef/extra-sql/doc/~/insertIntoStream
[setupTableIndex]: https://jsr.io/@nodef/extra-sql/doc/~/setupTableIndex
[createTableData]: https://jsr.io/@nodef/extra-sql/doc/~/createTableData
[updateData]: https://jsr.io/@nodef/extra-sql/doc/~/updateData
[selectData]: https://jsr.io/@nodef/extra-sql/doc/~/selectData
[insertIntoData]: https://jsr.io/@nodef/extra-sql/doc/~/insertIntoData
[deleteData]: https://jsr.io/@nodef/extra-sql/doc/~/deleteData