|
| 1 | +[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). |
| 2 | + |
| 3 | +▌ |
| 4 | +📦 [JSR](https://jsr.io/@nodef/extra-sql), |
| 5 | +📰 [Docs](https://jsr.io/@nodef/extra-sql/doc), |
| 6 | + |
| 7 | +<br> |
| 8 | + |
| 9 | + |
| 10 | +```javascript |
| 11 | +import * as xsql from "@nodef/extra-sql"; |
| 12 | + |
| 13 | +xsql.tableExists("food"); |
| 14 | +// → SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name='food'); |
| 15 | + |
| 16 | +xsql.setupTable("food", {code: "TEXT", name: "TEXT"}, |
| 17 | + [{code: "F1", name: "Mango"}, {code: "F2", name: "Lychee"}]); |
| 18 | +// → CREATE TABLE IF NOT EXISTS "food" ("code" TEXT, "name" TEXT); |
| 19 | +// → INSERT INTO "food" ("code", "name") VALUES |
| 20 | +// → ($$F1$$, $$Mango$$), |
| 21 | +// → ($$F2$$, $$Lychee$$); |
| 22 | + |
| 23 | + |
| 24 | +xsql.selectTsquery("columns", "total fat"); |
| 25 | +// → SELECT * FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat'); |
| 26 | + |
| 27 | +xsql.matchTsquery("columns", ["total", "fat"]); |
| 28 | +// → SELECT *, '2'::INT AS "matchTsquery" FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat') UNION ALL |
| 29 | +// → SELECT *, '1'::INT AS "matchTsquery" FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total'); |
| 30 | +``` |
| 31 | + |
| 32 | + |
| 33 | +## Index |
| 34 | + |
| 35 | +| Property | Description | |
| 36 | +| ---- | ---- | |
| 37 | +| [createTable] | Generate SQL command for CREATE TABLE. | |
| 38 | +| [createIndex] | Generate SQL command for CREATE INDEX. | |
| 39 | +| [createView] | Generate SQL command for CREATE VIEW. | |
| 40 | +| [insertInto] | Generates SQL command for INSERT INTO using an array of values. | |
| 41 | +| [setupTable] | Generate SQL commands to set up a table (create, insert, index). | |
| 42 | +| [tableExists] | Generate SQL command to check if a table exists. | |
| 43 | +| [selectTsquery] | Generate SQL command for SELECT with tsquery. | |
| 44 | +| [matchTsquery] | Generate SQL query for matching words with tsquery. | |
| 45 | +| [insertIntoStream] | Generate SQL command for INSERT INTO using a stream of values. | |
| 46 | +| [setupTableIndex] | Generate SQL commands for setting up table indexes and views. | |
| 47 | +| [createTableData] | Generate SQL command for creating a table with data. | |
| 48 | +| [updateData] | Generate SQL command for updating data. | |
| 49 | +| [selectData] | Generate SQL command for selecting data. | |
| 50 | +| [insertIntoData] | Generate SQL command for inserting data. | |
| 51 | +| [deleteData] | Generate SQL command for deleting data. | |
| 52 | +| [OPERATORS] | Set of operators in SQL. {field} | |
| 53 | +| [OPERAND_COUNT] | Number of operands used with an SQL operator. {field} | |
| 54 | + |
| 55 | +<br> |
| 56 | +<br> |
| 57 | + |
| 58 | + |
| 59 | +[](https://wolfram77.github.io)<br> |
| 60 | +[](https://nodef.github.io) |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +[SQL]: https://en.wikipedia.org/wiki/SQL |
| 65 | +[createTable]: https://jsr.io/@nodef/extra-sql/doc/~/createTable |
| 66 | +[createIndex]: https://jsr.io/@nodef/extra-sql/doc/~/createIndex |
| 67 | +[createView]: https://jsr.io/@nodef/extra-sql/doc/~/createView |
| 68 | +[insertInto]: https://jsr.io/@nodef/extra-sql/doc/~/insertInto |
| 69 | +[setupTable]: https://jsr.io/@nodef/extra-sql/doc/~/setupTable |
| 70 | +[tableExists]: https://jsr.io/@nodef/extra-sql/doc/~/tableExists |
| 71 | +[selectTsquery]: https://jsr.io/@nodef/extra-sql/doc/~/selectTsquery |
| 72 | +[matchTsquery]: https://jsr.io/@nodef/extra-sql/doc/~/matchTsquery |
| 73 | +[OPERATORS]: https://jsr.io/@nodef/extra-sql/doc/~/OPERATORS |
| 74 | +[OPERAND_COUNT]: https://jsr.io/@nodef/extra-sql/doc/~/OPERAND_COUNT |
| 75 | +[insertIntoStream]: https://jsr.io/@nodef/extra-sql/doc/~/insertIntoStream |
| 76 | +[setupTableIndex]: https://jsr.io/@nodef/extra-sql/doc/~/setupTableIndex |
| 77 | +[createTableData]: https://jsr.io/@nodef/extra-sql/doc/~/createTableData |
| 78 | +[updateData]: https://jsr.io/@nodef/extra-sql/doc/~/updateData |
| 79 | +[selectData]: https://jsr.io/@nodef/extra-sql/doc/~/selectData |
| 80 | +[insertIntoData]: https://jsr.io/@nodef/extra-sql/doc/~/insertIntoData |
| 81 | +[deleteData]: https://jsr.io/@nodef/extra-sql/doc/~/deleteData |
0 commit comments