Skip to content

Commit a043de7

Browse files
committed
wiki linked
1 parent 4af0270 commit a043de7

3 files changed

Lines changed: 49 additions & 16 deletions

File tree

README.md

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,51 @@
1-
SQL is designed for managing or stream processing data in an RDBMS.
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).
23

34
```javascript
4-
const extra = require('sql-extra');
5-
// extra.createTable(<name>, <columns>, [options])
6-
// extra.createIndex(<name>, <table>, <expression>, [options])
7-
// ...
5+
const sql = require('extra-sql');
6+
7+
sql.tableExists('food');
8+
// SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name='food');
9+
10+
sql.setupTable('food', {code: 'TEXT', name: 'TEXT'},
11+
[{code: 'F1', name: 'Mango'}, {code: 'F2', name: 'Lychee'}]);
12+
// CREATE TABLE IF NOT EXISTS "food" ("code" TEXT, "name" TEXT);
13+
// INSERT INTO "food" ("code", "name") VALUES
14+
// ('F1', 'Mango'),
15+
// ('F2', 'Lychee');
16+
17+
sql.selectTsquery('columns', 'total fat');
18+
// SELECT * FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat');
19+
20+
sql.matchTsquery('columns', ['total', 'fat']);
21+
// 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');
823
```
924

10-
Methods:
11-
- [createTable](https://www.npmjs.com/package/@sql-extra/createtable)
12-
- [createIndex](https://www.npmjs.com/package/@sql-extra/createindex)
13-
- [createView](https://www.npmjs.com/package/@sql-extra/createview)
14-
- [insertInto](https://www.npmjs.com/package/@sql-extra/insertinto)
15-
- [setupTable](https://www.npmjs.com/package/@sql-extra/setuptable)
16-
- [tableExists](https://www.npmjs.com/package/@sql-extra/tableexists)
17-
- [selectTsquery](https://www.npmjs.com/package/@sql-extra/selecttsquery)
18-
- [matchTsquery](https://www.npmjs.com/package/@sql-extra/matchtsquery)
25+
### reference
26+
27+
| Name | Action
28+
|---------------------|-------
29+
| [createTable] | Generates SQL command for CREATE TABLE.
30+
| [createIndex] | Generates SQL command for CREATE INDEX.
31+
| [createView] | Generates SQL command for CREATE VIEW.
32+
| [insertInto] | Generates SQL command for INSERT INTO.
33+
| [setupTable] | Generates SQL commands to setup table (create, insert, index).
34+
| [tableExists] | Generates SQL command for table exists check.
35+
| [selectTsquery] | Generates SQL command for SELECT with tsquery.
36+
| [matchTsquery] | Generates SQL query for matching words with tsquery.
37+
38+
<br>
39+
<br>
40+
41+
[![nodef](https://merferry.glitch.me/card/extra-sql.svg)](https://nodef.github.io)
42+
43+
[createTable]: https://github.com/nodef/extra-sql/wiki/createTable
44+
[createIndex]: https://github.com/nodef/extra-sql/wiki/createIndex
45+
[createView]: https://github.com/nodef/extra-sql/wiki/createView
46+
[insertInto]: https://github.com/nodef/extra-sql/wiki/insertInto
47+
[setupTable]: https://github.com/nodef/extra-sql/wiki/setupTable
48+
[tableExists]: https://github.com/nodef/extra-sql/wiki/tableExists
49+
[selectTsquery]: https://github.com/nodef/extra-sql/wiki/selectTsquery
50+
[matchTsquery]: https://github.com/nodef/extra-sql/wiki/matchTsquery
51+
[SQL]: https://en.wikipedia.org/wiki/SQL

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "extra-sql",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "SQL is designed for managing or stream processing data in an RDBMS.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)