Table factory.
- Mixes In:
Methods
-
<static> escapeIdentifier()
-
Internal utility function.
-
count()
-
Retrieve the total number of rows in the table.
Returns:
- Type
- Promise.<number>
-
delete( [expr])
-
Create operation to delete rows from a table.
Parameters:
Name Type Argument Description expr
SearchConditionStr <optional>
filtering criteria Returns:
The operation instance.- Type
- module:TableDelete
Example
// delete all rows from a table table.delete('true') // delete rows that match a given criteria table.delete('`name` == "foobar"')
-
existsInDatabase()
-
Check if the table exists in the database.
Returns:
- Type
- Promise.<boolean>
-
getName()
-
Retrieve the table name.
Returns:
- Type
- string
-
getSchema()
-
Retrieve the schema associated to the table.
Returns:
- Type
- module:Schema
-
insert(fields)
-
Create operation to insert rows in the table.
Parameters:
Name Type Description fields
string | Array.<string> | Object column names or column-value object Throws:
-
When the input type is invalid.
- Type
- Error
Returns:
The operation instance.- Type
- module:TableInsert
Example
// arguments as column names table.insert('foo', 'bar') // array of column names table.insert(['foo', 'bar']) // object with column name and value table.insert({ foo: 'baz', bar: 'qux' })
-
-
inspect()
-
Retrieve the table metadata.
Returns:
An object containing the relevant metadata.- Type
- Object
-
isView()
-
Check whether the table is a view.
Returns:
- Type
- Promise.<boolean>
-
select( [expr])
-
Create operation to select rows from the table.
Parameters:
Name Type Argument Description expr
string | Array.<string> <optional>
columns to be projected Throws:
-
When an expression is invalid.
- Type
- Error
Returns:
The operation instance.- Type
- module:TableSelect
Example
// all columns should be projected const selection = table.select() // arguments as columns to be projected const selection = table.select('foo', 'bar') // array of columns to be projected const selection = table.select(['foo', 'bar'])
-
-
update( [expr])
-
Create operation to update rows in the table.
Parameters:
Name Type Argument Description expr
string <optional>
filtering criteria Returns:
The operation instance.- Type
- module:TableUpdate
Example
// update all rows in a table table.update('true').set('name', 'foo') table.update().where('true').set('name', 'foo') // update rows that match a given criteria table.update().where('`name` == "foo"').set('name', 'bar')