Constructor
new DataContext(database, escaper, queryExecuter)
Initialize the DC.
Parameters:
Name | Type | Description |
---|---|---|
database |
Database | A Database instance to query. |
escaper |
Escaper | An instance of an Escaper matching the database type (i.e. MySQLEscaper or MSSQLEscaper). |
queryExecuter |
QueryExecuter | queryExecuter A QueryExecuter instance. |
- Source:
Members
database
Properties:
Name | Type | Description |
---|---|---|
database |
Database | A database instance. |
escaper |
Escaper | An instance of an Escaper class that can escape query parts. |
queryExecuter |
QueryExecuter | An instance of a QueryExecuter that can execute CRUD operations. |
- Source:
Methods
delete(model, databaseopt) → {DeleteModel}
Create a new DeleteModel instance that can be used to delete a
model by ID. For complex DELETE operations, use the DataContext#from method to obtain a FromAdapter instance, and
then call FromAdapter#delete on that instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
model |
Object | See the DeleteModel constructor. | |
database |
Database |
<optional> |
An optional Database instance. If passed, this parameter is used instead of the Database that's provided to the ctor. |
- Source:
Returns:
A DeleteModel instance.
- Type
- DeleteModel
end() → {void}
End the connection.
- Source:
Returns:
- Type
- void
from(meta, databaseopt) → {FromAdapter}
Create a new FromAdapter instance, which can then be used to
SELECT, DELETE, or UPDATE.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
meta |
TableMetaList~TableMeta | string | See the From constructor. | |
database |
Database |
<optional> |
An optional Database instance. If passed, this parameter is used instead of the Database that's provided to the ctor. |
- Source:
- See:
Returns:
A FromAdapter instance.
- Type
- FromAdapter
insert(model, databaseopt) → {Insert}
Create a new Insert instance. Driver-specific DataContext
implementations must implement this method.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
model |
Object | See the Insert constructor. | |
database |
Database |
<optional> |
An optional Database instance. If passed, this parameter is used instead of the Database that's provided to the ctor. |
- Source:
Returns:
An Insert instance.
- Type
- Insert
update(model, databaseopt) → {UpdateModel}
Create a new UpdateModel instance that can be used to UPDATE a model by
ID. For complex UPDATE operations, use the DataContext#from
method to obtain a FromAdapter instance, and then call FromAdapter#update on that instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
model |
Object | See the UpdateModel constructor. | |
database |
Database |
<optional> |
An optional Database instance. If passed, this parameter is used instead of the Database that's provided to the ctor. |
- Source:
Returns:
A UpdateModel instance.
- Type
- UpdateModel