Constructor
new Insert(database, escaper, queryExecuter, model)
Initialize the Query.
Parameters:
Name | Type | Description |
---|---|---|
database |
Database | A Database instance that will be queried. |
escaper |
Escaper | An instance of an Escaper matching the database type (i.e. MySQLEscaper or MSSQLEscaper). |
queryExecuter |
QueryExecuter | A QueryExecuter instance. |
model |
Object | A model object to insert. Each key in the object should map to a table. The value associated with the key should be an object or an array of objects wherein each key maps to a column. |
- Source:
Extends
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. |
- Inherited From:
- Source:
Methods
buildQuery() → {Query~QueryMeta}
Build the query.
- Inherited From:
- Source:
Returns:
The string-representation of the query to
execute along with any query parameters.
- Type
- Query~QueryMeta
execute() → {Promise.<Object>}
Execute the query.
- Source:
Returns:
A promise that shall be resolved with the
model. If the underlying queryExecuter returns the insertId of the
model, the model will be updated with the ID. If an error occurs during
execution, the promise shall be rejected with the error (unmodified).
- Type
- Promise.<Object>
toString() → {string}
Create the SQL string.
- Source:
Returns:
A SQL representation of the INSERT query, as a string.
- Type
- string