Skip to content

Commit 113a471

Browse files
🗃️ Update doc/sql.txt
1 parent c9b2f56 commit 113a471

1 file changed

Lines changed: 36 additions & 76 deletions

File tree

doc/sql.txt

Lines changed: 36 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,14 @@ https://github.com/tami5/sql.nvim
88
:h sql
99
:h sql.table
1010

11-
SQLDatabase *SQLDatabase*
11+
sqldb *sqldb*
1212
Main sql.nvim object.
1313

1414
Fields: ~
15-
{uri} (string) database uri
16-
{conn} (sqlite3_blob) sqlite connection c object.
17-
18-
19-
SqlSchemaKeyDefinition *SqlSchemaKeyDefinition*
20-
21-
22-
Fields: ~
23-
{cid} (number) column index
24-
{name} (string) column key
25-
{type} (string) column type
26-
{required} (boolean) whether the column key is required or not
27-
{primary} (boolean) whether the column is a primary key
28-
{default} (string) the default value of the column
29-
{reference} (string) table_name.column
30-
{on_update} (SqliteActions) what to do when the key gets updated
31-
{on_delete} (SqliteActions) what to do when the key gets deleted
32-
33-
34-
SQLQuerySpec *SQLQuerySpec*
35-
Query spec that are passed to a number of db: methods.
36-
37-
Fields: ~
38-
{where} (table) key and value
39-
{values} (table) key and value to updated.
40-
41-
42-
SQLDatabaseExt : SQLDatabase *SQLDatabaseExt*
43-
Extend sql.nvim object
44-
45-
Parents: ~
46-
|SQLDatabase|
47-
48-
Fields: ~
49-
{db} (SQLDatabase) fallback when the user overwrite @SQLDatabaseExt
50-
methods.
51-
52-
53-
SQLDatabaseStatus *SQLDatabaseStatus*
54-
55-
56-
Fields: ~
57-
{msg} (string)
58-
{code} (sqlite3_flag)
15+
{uri} (string) database uri
16+
{conn} (sqlite_blob) sqlite connection c object.
17+
{db} (sqldb) fallback when the user overwrite @sqldb methods
18+
(extended only).
5919

6020

6121
DB.new({uri}, {opts}) *DB.new()*
@@ -70,7 +30,7 @@ DB.new({uri}, {opts}) *DB.new()*
7030
https://www.sqlite.org/pragma.html
7131

7232
Return: ~
73-
SQLDatabase
33+
sqldb
7434

7535
Usage: ~
7636
`require'sql'.new()` in memory
@@ -91,7 +51,7 @@ DB:open({uri}, {opts}) *DB:open()*
9151
{opts} (table)
9252

9353
Return: ~
94-
SQLDatabase
54+
sqldb
9555

9656
Usage: ~
9757
`require("sql"):open()` in memory.
@@ -100,17 +60,15 @@ DB:open({uri}, {opts}) *DB:open()*
10060
`db:open()` reopen connection if closed.
10161

10262

103-
DB:extend({sql}, {tbl}, {opts}) *DB:extend()*
104-
Use to Extend SQLDatabase Object with extra sugar syntax and api.
63+
DB:extend({opts}) *DB:extend()*
64+
Use to Extend sqldb Object with extra sugar syntax and api.
10565

10666

10767
Parameters: ~
108-
{sql} (SQLDatabase)
109-
{tbl} (SQLTable)
110-
{opts} (table) uri, init, opts, tbl_name, tbl_name ....
68+
{opts} (table) uri, init, opts, tbl_name, tbl_name ....
11169

11270
Return: ~
113-
SQLDatabaseExt
71+
sqldb
11472

11573
Usage: ~
11674
`local tbl = require('sql.table'):extend("tasks", { ... })` --
@@ -186,7 +144,7 @@ DB:status() *DB:status()*
186144

187145

188146
Return: ~
189-
SQLDatabaseStatus
147+
sqldb_status
190148

191149

192150
DB:eval({statement}, {params}) *DB:eval()*
@@ -247,8 +205,8 @@ DB:create({tbl_name}, {schema}) *DB:create()*
247205

248206

249207
Parameters: ~
250-
{tbl_name} (string) table name
251-
{schema} (table<string, SqlSchemaKeyDefinition>)
208+
{tbl_name} (string) table name
209+
{schema} (sqlschema)
252210

253211
Return: ~
254212
boolean
@@ -281,7 +239,7 @@ DB:schema({tbl_name}) *DB:schema()*
281239
{tbl_name} (string) the table name.
282240

283241
Return: ~
284-
table<string, SqlSchemaKeyDefinition>
242+
sqlschema
285243

286244

287245
DB:insert({tbl_name}, {rows}) *DB:insert()*
@@ -308,8 +266,9 @@ DB:update({tbl_name}, {specs}) *DB:update()*
308266

309267

310268
Parameters: ~
311-
{tbl_name} (string) the name of the db table.
312-
{specs} (SQLQuerySpec|SQLQuerySpec[])
269+
{tbl_name} (string) the name of the db
270+
table.
271+
{specs} (sqlquery_update|sqlquery_update[])
313272

314273
Return: ~
315274
boolean
@@ -329,8 +288,9 @@ DB:delete({tbl_name}, {where}) *DB:delete()*
329288

330289

331290
Parameters: ~
332-
{tbl_name} (string) the name of the db table.
333-
{where} (table) keys and their values
291+
{tbl_name} (string) the name of the db table.
292+
{where} (sqlquery_delete) key value pair to where delete operation
293+
should effect.
334294

335295
Return: ~
336296
boolean: true if operation is successfully, false otherwise.
@@ -349,8 +309,8 @@ DB:select({tbl_name}, {spec}) *DB:select()*
349309

350310

351311
Parameters: ~
352-
{tbl_name} (string) the name of the db table to select on
353-
{spec} (SQLQuerySpec)
312+
{tbl_name} (string) the name of the db table to select on
313+
{spec} (sqlquery_select)
354314

355315
Return: ~
356316
table[]
@@ -374,7 +334,7 @@ DB:table({tbl_name}, {opts}) *DB:table()*
374334
{opts} (table) {schema, ensure (defalut true)}
375335

376336
Return: ~
377-
SQLTable
337+
sqltale
378338

379339

380340
DB.lib() *DB.lib()*
@@ -388,24 +348,24 @@ DB.lib() *DB.lib()*
388348

389349
Abstraction to produce more readable code.
390350

391-
SQLTable *SQLTable*
351+
sqltbl *sqltbl*
392352
Main table class
393353

394354
Fields: ~
395-
{db} (SQLDatabase) database in which the tbl is part of.
355+
{db} (sqldb) database in which the tbl is part of.
396356

397357

398358
tbl:new({db}, {name}, {schema}) *tbl:new()*
399359
Create new sql table object
400360

401361

402362
Parameters: ~
403-
{db} (SQLDatabase)
404-
{name} (string) table name
405-
{schema} (table<string, SqlSchemaKeyDefinition>)
363+
{db} (sqldb)
364+
{name} (string) table name
365+
{schema} (sqlschema)
406366

407367
Return: ~
408-
SQLTable
368+
sqltbl
409369

410370

411371
tbl:extend({db}, {name}, {schema}) *tbl:extend()*
@@ -415,12 +375,12 @@ tbl:extend({db}, {name}, {schema}) *tbl:extend()*
415375

416376

417377
Parameters: ~
418-
{db} (SQLDatabase)
378+
{db} (sqldb)
419379
{name} (string)
420-
{schema} (table<string, SqlSchemaKeyDefinition>)
380+
{schema} (sqlschema)
421381

422382
Return: ~
423-
SQLTableExt
383+
sqltbl.ext
424384

425385

426386
tbl:schema({schema}) *tbl:schema()*
@@ -430,10 +390,10 @@ tbl:schema({schema}) *tbl:schema()*
430390

431391

432392
Parameters: ~
433-
{schema} (table<string, SqlSchemaKeyDefinition>)
393+
{schema} (sqlschema)
434394

435395
Return: ~
436-
table<string, SqlSchemaKeyDefinition> | boolean
396+
sqlschema | boolean
437397

438398
Usage: ~
439399
`projects:schema()` get project table schema.
@@ -490,7 +450,7 @@ tbl:get({query}) *tbl:get()*
490450

491451

492452
Parameters: ~
493-
{query} (table) query.where, query.keys, query.join
453+
{query} (sqlquery_select)
494454

495455
Return: ~
496456
table

0 commit comments

Comments
 (0)