0.1.1 • Published 7 months ago

dal-lite v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

dal-lite

Modules

dals/sqlite3

dals/sqlite3~SqliteDal ⇐ Dal

DAL that connects to sqlite3 databases

Kind: inner class of dals/sqlite3
Extends: Dal
See: module:index~Dal

sqliteDal.type

Kind: instance property of SqliteDal
See: module:index.Dal#type

sqliteDal.connect()

Kind: instance method of SqliteDal
See: Dal.connect

sqliteDal.tableExists()

Kind: instance method of SqliteDal
See: Dal.tableExists

sqliteDal.createTable()

Kind: instance method of SqliteDal
See: Dal.createTable

sqliteDal.dropTable()

Kind: instance method of SqliteDal
See: Dal.dropTable

sqliteDal.exec()

Kind: instance method of SqliteDal
See: Dal.exec

sqliteDal.query()

Kind: instance method of SqliteDal
See: Dal.query

sqliteDal.quoteIdentifier()

Kind: instance method of SqliteDal
See: Dal.quoteIdentifier

sqliteDal.quoteValue()

Kind: instance method of SqliteDal
See: Dal.quoteValue

sqliteDal.insert()

Kind: instance method of SqliteDal
See: Dal.insert

sqliteDal.update()

Kind: instance method of SqliteDal
See: Dal.update

sqliteDal.select()

Kind: instance method of SqliteDal
See: Dal.select

sqliteDal.delete()

Kind: instance method of SqliteDal
See: Dal.delete

sqliteDal.close()

Kind: instance method of SqliteDal
See: Dal.close

index

index~Dal

Abstract class that selects a DAL for a given connection string (URI) via @function getDal

Kind: inner class of index

new Dal(uri, _options)

ParamTypeDescription
uristringConnection string used to attach to the database
_optionsobjectOptions

dal.type ⇒ string

Gets the underlying DAL type of this DAL

Kind: instance abstract property of Dal
Returns: string - The underlying DAL type

dal.connect(_options) ⇒ Promise

Connects the specified database. This is only necessary if you specified connect=false in the options to getDal

Kind: instance abstract method of Dal

ParamTypeDescription
_optionsobjectOptions

dal.tableExists(table, _options) ⇒ Promise

Checks if a table exists

Kind: instance abstract method of Dal

ParamTypeDescription
tableTableSpecTable specifier
_optionsobjectOptions

dal.createTable(table, tableDef, _options) ⇒ Promise

Creates a table from a given table definition

Kind: instance abstract method of Dal

ParamTypeDescription
tableTableSpecTable specifier TableSpec
tableDefTableDefTable definition
_optionsobjectOptions

dal.alterTable(table, defChanges, _options) ⇒ Promise

Alters an existing table to match a given table definition

Kind: instance abstract method of Dal
Returns: Promise - Promise that resolves when table is altered or rejects for errors

ParamTypeDescription
tableTableSpecTable specifier
defChangesobjectChanges to apply to table
_optionsobjectOptions

dal.dropTable(table, _options) ⇒ Promise

Kind: instance abstract method of Dal
Returns: Promise - Promise that resolves for successful table drop or rejects for errors

ParamTypeDescription
tableTableSpecTable specifier
_optionsobjectOptions

dal.quoteIdentifier(name, _options) ⇒ string

Quotes a given identifier (e.g. table, column name)

Kind: instance abstract method of Dal
Returns: string - Quoted name

ParamTypeDescription
namestring
_optionsobjectOptions

dal.quoteValue(value, type, _options) ⇒ string

Quotes a given value according to a specified type

Kind: instance abstract method of Dal
Returns: string - Quoted value

ParamTypeDescription
value*
typestring
_optionsobjectOptions

dal.exec(sql, _options) ⇒ Promise

Executes a given SQL query that does not return data

Kind: instance abstract method of Dal
Returns: Promise - Promise that will resolve with no data or reject

ParamTypeDescription
sqlstringThe query
_optionsobjectOptions

dal.query(sql, _options) ⇒ Promise

Run a query that returns data from the database.

Kind: instance abstract method of Dal
Returns: Promise - Promise that resolves with data or rejects

ParamTypeDescription
sqlstringThe query
_optionsobjectOptions

dal.insert(into, values, _options) ⇒ Promise

Insert data into the database.

Kind: instance abstract method of Dal
Returns: Promise - Promise that resolves for a successful insert or rejects

ParamTypeDescription
intoTableSpecTable specifier
valuesobject | Array.<object>Array or singular column to value map (object where keys are the column name and the values are the values for the column).
_optionsobjectOptions

dal.update(table, changes, _options) ⇒ Promise

Update data within the database.

Kind: instance abstract method of Dal
Returns: Promise - Promise that resolves for a successful update or rejects

ParamTypeDefaultDescription
tableTableSpecTable specifier
changesArray.<ChangeDef>
_optionsobjectOptions
_options.wherestringWhere clause

dal.select(columns, from, _options) ⇒ Promise

Select data from the database

Kind: instance abstract method of Dal
Returns: Promise - Promise that resolves with returned data or rejects

ParamTypeDescription
columnsArray.<string>
fromTableSpecTable specifier
_optionsobjectOptions
_options.wherestringWhere clause
_options.groupBystringGroup by clause
_options.orderBystringOrder by clause
_options.limit.limitnumberLimit results to this value
_options.limit.offsetnumberOffset results by this value

dal.delete(from, _options) ⇒ Promise

Delete data from the database.

Kind: instance abstract method of Dal
Returns: Promise - Promise that resolves with a successful delete or rejects

ParamTypeDescription
fromTableSpecTable specifier TODO joins, etc.
_optionsobjectOptions
_options.wherestringWhere clause

dal.applyDataDefinition(def, _options) ⇒ Promise

Uses a DataDef to specify a desired database schema state.

Kind: instance method of Dal
Returns: Promise - Promise that resolves for successful application or rejects

ParamTypeDescription
defDataDefDataDef describing the expected state of the database
_optionsobjectOptions

dal.close() ⇒ Promise

Closes the connection to the database. The instance should not be used after this.

Kind: instance abstract method of Dal
Returns: Promise - Promise that resolves when the connection is closed or rejects for errors

Dal.getDal(uri, _options) ⇒ Dal

Given a connection string (URI) chooses a matching subclass of Dal that implements that database dialect and instantiates it

Kind: static method of Dal
Returns: Dal - The subclass of Dal for the database type specified by the uri

ParamTypeDescription
uristringConnection string/URI
_optionsobjectOptions
_options.connectbooleanAuto-connect to the database. Defaults to true.

index~TableSpec : string | object | Array.<string>

Table specifier. Can be a string, an array or an object. If a string, the simple (no schema) name of the table. If an array, it must have a length of 2; the first element is the schema, the second element is the table name. If an object, it must have a property tableName that is the name of the table and an optional property schema that is the name of the schema.

Kind: inner typedef of index
Properties

NameTypeDescription
tablestringThe table name
schemastringThe table schema

index~ColumnDef : object

Column definition.

Kind: inner typedef of index
Properties

NameTypeDescription
typestringType of the column (based on types compatible with underlying DAL)
notNullbooleanTrue if column can contain NULL values. Defaults to false.

index~PrimaryKeyDef : string | Array.<string>

Primary key definition. Can be a column name or an array of column names.

Kind: inner typedef of index

index~ForeignKeyDef : object

Foreign key definition.

Kind: inner typedef of index
Properties

NameTypeDescription
columnsstring | Array.<string>Array of column names or string of a singular column name
referencesobjectDefinition of the target the column references.
references.tablestringName of the table referenced.
references.columnsstring | Array.<string>Names of the columns or singular name referenced by this foreign key. Should match up with .columns

index~TableDef : object

Table definition.

Kind: inner typedef of index
Properties

NameTypeDescription
columnsObject.<string, ColumnDef>Object keyed with column names mapping to ColumnDefs
primaryKeyPrimaryKeyDefPrimary key definition
foreignKeysArray.<ForeignKeyDef>Definitions of foreign keys within the table

index~IndexDef : object

Index definition.

Kind: inner typedef of index

index~ViewDef : object

View definition.

Kind: inner typedef of index

index~DataDef : object

Database schema definition.

Kind: inner typedef of index
Properties

NameTypeDescription
tablesArray.<TableDef>The individual TableDefs
indexesArray.<IndexDef>The individual IndexDefs
viewsArray.<ViewDef>The individual ViewDefs

index~ChangeDef : object

Change to apply to a table's data

Kind: inner typedef of index
Properties

NameTypeDescription
columnstringThe column to update
value*The new value of the column
0.1.1

7 months ago

0.1.0

7 months ago

0.0.6

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago