Table factory.
- Mixes In:
Methods
-
count()
-
Retrieves the total number of documents in the table. This method executes a statement in the database.
Returns:
APromise
that resolves to the number of documents in the table.- Type
- Promise.<number>
-
delete()
-
Creates a statement that updates all rows that match a criteria. The criteria is required and should be defined using the TableFiltering.where() method. This method does not cause the statement to be executed.
- See:
Returns:
A new instance of a statement containing the filtering criteria which will be used for determining which rows will be deleted.- 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()
-
Checks if this table exists in the database. This method executes a statement in the database.
Returns:
APromise
that resolves to a boolean value which indicates whether the table exists or not.- Type
- Promise.<boolean>
-
getName()
-
Retrieves the table name. This method works with the local table instance and does not execute any statement in the database.
Returns:
The Name of the table.- Type
- string
-
getSchema()
-
Retrieves the instance of the schema where the table lives under. This method works with the local table instance and does not execute any statement in the database.
Returns:
The instance of the schema where statements will be executed.- Type
- module:Schema
-
insert(tableFields)
-
Creates a statement that inserts one or more rows in the table. This method does not cause the statement to be executed.
Parameters:
Name Type Argument Description tableFields
TableFields <repeatable>
The Names of the columns where the values will be inserted for each row. - See:
Throws:
Column name is not a valid string or X DevAPI expression instance.Returns:
A new instance of a statement containing the column names of the rows to be inserted.- 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()
-
Retrieves the table metadata. This method works with the local table instance and does not execute any statement in the database.
Returns:
An Object containing metadata about the table.- Type
- Object
-
isView()
-
Checks if the table is a view (virtual) or an actual table. This method executes a statement in the database.
Returns:
APromise
that resolves to a boolean that indicates whether the table is a view or not.- Type
- Promise.<boolean>
-
select( [projectedSearchExprStrs])
-
Creates a statement that retrieves the values for the given column names on each table row that matches a criteria. The criteria is optional and should be defined using the TableFiltering.where() method. This method does not cause the statement to be executed.
Parameters:
Name Type Argument Description projectedSearchExprStrs
ProjectedSearchExprStrList <optional>
<repeatable>
One or more names of columns to include in the result set. - See:
Returns:
A new instance of a statement containing the names of the columns to include in the result set for all the rows that match the criteria.- 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()
-
Creates a statement that updates all rows that match a criteria, The criteria is required and should be defined using the TableFiltering.where() method. This method does not cause the statement to be executed.
- See:
Returns:
A new instance of a statement containing the filtering criteria which will be used for determining which rows will be updated.- 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')
-
<static> escapeIdentifier()
-
Internal utility function.