Constructor
new Instance()
Methods
alterTable(name) → {AlterTable}
Alters a table and updates to the new given structure.
Parameters:
| Name | Type | Description |
|---|---|---|
name | String |
Returns:
- Type:
- AlterTable
(async) checkStructure(table, desiredStructure, databaseopt) → {CheckResult}
Checks the structure of a table
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
table | String | Name of the table | |
desiredStructure | Structure | Structure to check against | |
database | String | <optional> | Name of the database. If omitted, uses default database |
Returns:
- Type:
- CheckResult
connect() → {undefined}
Connects the instance
Returns:
- Type:
- undefined
(async) createDatabase(name) → {Any}
Creates a new database - Requires admin privileges
Parameters:
| Name | Type | Description |
|---|---|---|
name | String | Name of the database to create |
Returns:
- Type:
- Any
createStructure() → {Structure}
Prepares to create a new table-structure
Returns:
- Type:
- Structure
createTable(name) → {CreateTable}
Prepares to create a new table
Parameters:
| Name | Type | Description |
|---|---|---|
name | String | Name of the table to create |
Returns:
- Type:
- CreateTable
delete(from) → {Delete}
Prepares a new delete query
Parameters:
| Name | Type | Description |
|---|---|---|
from | String | Name of the table to delete from |
Returns:
- Type:
- Delete
destroy() → {true}
Destroys the instance
Returns:
- Type:
- true
(async) dropDatabase(database) → {Any}
Drops a whole database - Requires admin privileges
Parameters:
| Name | Type | Description |
|---|---|---|
database | String | Name of the database to drop |
Returns:
- Type:
- Any
(async) dropTable(table) → {Any}
Drops a whole table
Parameters:
| Name | Type | Description |
|---|---|---|
table | String | Name of the table to drop |
Returns:
- Type:
- Any
(async) getDatabases(excludeSchema) → {Array.<String>}
Returns a list of database names the user has access to
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
excludeSchema | Boolean | false | Whether to exclude the default database 'information_schema' |
Returns:
- Type:
- Array.<String>
(async) getStructure(table, databaseopt) → {Structure}
Returns the structure object of a table
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
table | String | Name of table to get structure of | |
database | String | <optional> | Name of the underlying database |
Returns:
- Type:
- Structure
(async) getTables(databaseopt) → {Array}
Returns a list of tables for the selected database - 'multipleStatements' must be active for this to work
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
database | String | <optional> | Database to select. Can be empty as long as a default database was set with 'selectDatabase' |
Returns:
- Type:
- Array
insert(into) → {Insert}
Prepares a new query to insert data
Parameters:
| Name | Type | Description |
|---|---|---|
into | String | Name of the table to insert into |
Returns:
- Type:
- Insert
isConnected() → {Boolean}
Returns if connection is established
Returns:
- Type:
- Boolean
queryRaw(queryString, values) → {Any}
Performs a raw query
Parameters:
| Name | Type | Description |
|---|---|---|
queryString | String | The sql query string to perform. |
values | Array.<Any> | An array holding all replacable ?-values from left to right. |
Returns:
- The individual result of your query
- Type:
- Any
select(from, …columnsopt) → {Select}
Prepares a new select query
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
from | String | Name of the table | |
columns | String | <optional> <repeatable> | Name of columns to select. Leave empty to select all |
Returns:
- Type:
- Select
selectDatabase(name) → {this}
Selects a default database for future queries
Parameters:
| Name | Type | Description |
|---|---|---|
name | String | Name of the database |
Returns:
- Type:
- this
(async) total(table) → {Any}
Returns total amount of rows of a table
Parameters:
| Name | Type | Description |
|---|---|---|
table | String | Table name |
Returns:
- Type:
- Any
update(table) → {Update}
Prepares a new update query
Parameters:
| Name | Type | Description |
|---|---|---|
table | String | Name of the table to update data in |
Returns:
- Type:
- Update