|
1 | | -[SQL] is designed for managing or stream processing data in an RDBMS. |
2 | | -Includes SQL command generation functions, with a few for text matching (PostgreSQL). |
| 1 | +[SQL] is designed for managing or stream processing data in an RDBMS. Includes SQL command generation functions, with a few for text matching (PostgreSQL). |
3 | 2 |
|
4 | 3 | ```javascript |
5 | | -const sql = require('extra-sql'); |
| 4 | +const xsql = require('extra-sql'); |
6 | 5 |
|
7 | | -sql.tableExists('food'); |
| 6 | +xsql.tableExists('food'); |
8 | 7 | // SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name='food'); |
9 | 8 |
|
10 | | -sql.setupTable('food', {code: 'TEXT', name: 'TEXT'}, |
| 9 | +xsql.setupTable('food', {code: 'TEXT', name: 'TEXT'}, |
11 | 10 | [{code: 'F1', name: 'Mango'}, {code: 'F2', name: 'Lychee'}]); |
12 | 11 | // CREATE TABLE IF NOT EXISTS "food" ("code" TEXT, "name" TEXT); |
13 | 12 | // INSERT INTO "food" ("code", "name") VALUES |
14 | 13 | // ('F1', 'Mango'), |
15 | 14 | // ('F2', 'Lychee'); |
16 | 15 |
|
17 | | -sql.selectTsquery('columns', 'total fat'); |
| 16 | +xsql.selectTsquery('columns', 'total fat'); |
18 | 17 | // SELECT * FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat'); |
19 | 18 |
|
20 | | -sql.matchTsquery('columns', ['total', 'fat']); |
| 19 | +xsql.matchTsquery('columns', ['total', 'fat']); |
21 | 20 | // SELECT *, '2'::INT AS "matchTsquery" FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat') UNION ALL |
22 | | -// SELECT *, '1'::INT AS "matchTsquery" FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total'); |
| 21 | +// SELECT *, '1'::INT AS "matchTsquery" FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total'); |
23 | 22 | ``` |
24 | 23 |
|
25 | | -### reference |
| 24 | + |
| 25 | +## Index |
26 | 26 |
|
27 | 27 | | Name | Action |
28 | 28 | |---------------------|------- |
|
0 commit comments