Skip to content

Commit

Permalink
🗃️ Update doc/sql.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 30, 2021
1 parent 657b591 commit 3e7e6fa
Showing 1 changed file with 35 additions and 79 deletions.
114 changes: 35 additions & 79 deletions doc/sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,14 @@ https://github.com/tami5/sql.nvim
:h sql
:h sql.table

SQLDatabase *SQLDatabase*
sqldb *sqldb*
Main sql.nvim object.

Fields: ~
{uri} (string) database uri
{conn} (sqlite3_blob) sqlite connection c object.


SqlSchemaKeyDefinition *SqlSchemaKeyDefinition*


Fields: ~
{cid} (number) column index
{name} (string) column key
{type} (string) column type
{required} (boolean) whether the column key is required or not
{primary} (boolean) whether the column is a primary key
{default} (string) the default value of the column
{reference} (string) table_name.column
{on_update} (SqliteActions) what to do when the key gets updated
{on_delete} (SqliteActions) what to do when the key gets deleted


SQLQuerySpec *SQLQuerySpec*
Query spec that are passed to a number of db: methods.

Fields: ~
{where} (table) key and value
{values} (table) key and value to updated.


SQLDatabaseExt : SQLDatabase *SQLDatabaseExt*
Extend sql.nvim object

Parents: ~
|SQLDatabase|

Fields: ~
{db} (SQLDatabase) fallback when the user overwrite @SQLDatabaseExt
methods.


SQLDatabaseStatus *SQLDatabaseStatus*


Fields: ~
{msg} (string)
{code} (sqlite3_flag)
{uri} (string) database uri
{conn} ()
{db} (sqldb) fallback when the user overwrite @sqldb methods
(extended only).


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

Return: ~
SQLDatabase
sqldb

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

Return: ~
SQLDatabase
sqldb

Usage: ~
`require("sql"):open()` in memory.
Expand All @@ -101,16 +61,16 @@ DB:open({uri}, {opts}) *DB:open()*


DB:extend({sql}, {tbl}, {opts}) *DB:extend()*
Use to Extend SQLDatabase Object with extra sugar syntax and api.
Use to Extend sqldb Object with extra sugar syntax and api.


Parameters: ~
{sql} (SQLDatabase)
{tbl} (SQLTable)
{opts} (table) uri, init, opts, tbl_name, tbl_name ....
{sql} (sqldb)
{tbl} (sqltable)
{opts} (table) uri, init, opts, tbl_name, tbl_name ....

Return: ~
SQLDatabaseExt
sqldb

Usage: ~
`local tbl = require('sql.table'):extend("tasks", { ... })` --
Expand Down Expand Up @@ -186,7 +146,7 @@ DB:status() *DB:status()*


Return: ~
SQLDatabaseStatus
sqldb.status


DB:eval({statement}, {params}) *DB:eval()*
Expand Down Expand Up @@ -247,8 +207,8 @@ DB:create({tbl_name}, {schema}) *DB:create()*


Parameters: ~
{tbl_name} (string) table name
{schema} (table<string, SqlSchemaKeyDefinition>)
{tbl_name} (string) table name
{schema} (table<string, sqltbl_key>)

Return: ~
boolean
Expand Down Expand Up @@ -281,7 +241,7 @@ DB:schema({tbl_name}) *DB:schema()*
{tbl_name} (string) the table name.

Return: ~
table<string, SqlSchemaKeyDefinition>
table<string, sqltbl_key>


DB:insert({tbl_name}, {rows}) *DB:insert()*
Expand All @@ -308,8 +268,9 @@ DB:update({tbl_name}, {specs}) *DB:update()*


Parameters: ~
{tbl_name} (string) the name of the db table.
{specs} (SQLQuerySpec|SQLQuerySpec[])
{tbl_name} (string) the name of the db
table.
{specs} (sqlquery.update | sqlquery.update[])

Return: ~
boolean
Expand All @@ -323,14 +284,13 @@ DB:update({tbl_name}, {specs}) *DB:update()*
status = "later" } )` update multiple rows


DB:delete({tbl_name}, {where}) *DB:delete()*
DB:delete({tbl_name}) *DB:delete()*
Delete a {tbl_name} row/rows based on the {specs} given. if no spec was
given, then all the {tbl_name} content will be deleted.


Parameters: ~
{tbl_name} (string) the name of the db table.
{where} (table) keys and their values

Return: ~
boolean: true if operation is successfully, false otherwise.
Expand All @@ -344,13 +304,12 @@ DB:delete({tbl_name}, {where}) *DB:delete()*
ids or greater than 5


DB:select({tbl_name}, {spec}) *DB:select()*
DB:select({tbl_name}) *DB:select()*
Query from a table with where and join options


Parameters: ~
{tbl_name} (string) the name of the db table to select on
{spec} (SQLQuerySpec)
{tbl_name} (string) the name of the db table to select on

Return: ~
table[]
Expand All @@ -374,7 +333,7 @@ DB:table({tbl_name}, {opts}) *DB:table()*
{opts} (table) {schema, ensure (defalut true)}

Return: ~
SQLTable
sqltale


DB.lib() *DB.lib()*
Expand All @@ -388,24 +347,24 @@ DB.lib() *DB.lib()*

Abstraction to produce more readable code.

SQLTable *SQLTable*
sqltbl *sqltbl*
Main table class

Fields: ~
{db} (SQLDatabase) database in which the tbl is part of.
{db} (sqldb) database in which the tbl is part of.


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


Parameters: ~
{db} (SQLDatabase)
{name} (string) table name
{schema} (table<string, SqlSchemaKeyDefinition>)
{db} (sqldb)
{name} (string) table name
{schema} (table<string, sqltbl.key>)

Return: ~
SQLTable
sqltbl


tbl:extend({db}, {name}, {schema}) *tbl:extend()*
Expand All @@ -415,12 +374,12 @@ tbl:extend({db}, {name}, {schema}) *tbl:extend()*


Parameters: ~
{db} (SQLDatabase)
{db} (sqldb)
{name} (string)
{schema} (table<string, SqlSchemaKeyDefinition>)
{schema} (table<string, sqltbl.key>)

Return: ~
SQLTableExt
sqltbl.ext


tbl:schema({schema}) *tbl:schema()*
Expand All @@ -430,10 +389,10 @@ tbl:schema({schema}) *tbl:schema()*


Parameters: ~
{schema} (table<string, SqlSchemaKeyDefinition>)
{schema} (table<string, sqltbl.key>)

Return: ~
table<string, SqlSchemaKeyDefinition> | boolean
table<string, sqltbl.key> | boolean

Usage: ~
`projects:schema()` get project table schema.
Expand Down Expand Up @@ -485,13 +444,10 @@ tbl:count() *tbl:count()*
number


tbl:get({query}) *tbl:get()*
tbl:get() *tbl:get()*
Query the table and return results.


Parameters: ~
{query} (table) query.where, query.keys, query.join

Return: ~
table

Expand Down

0 comments on commit 3e7e6fa

Please sign in to comment.