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