PreparedQuery
Class that presents a simple interface for constructing queries for a relational database using a model map object describing the connections between models.
All methods except exec
are chainable.
Constructor Summary
Public Constructor | ||
public |
constructor(modelId: String, models: JoinJsMap, knex: KnexInstance) Generally, this shouldn't be called by external code. This object is generated by the main
interface when the |
Member Summary
Public Members | ||
public |
knex: * |
|
public |
modelId: * |
|
public |
models: * |
|
public |
|
|
public |
populated: *[] |
|
public |
sortAttr: * |
|
public |
sortDir: * |
|
public |
whereClauses: *[] |
Method Summary
Public Methods | ||
public |
Run the query and construct a nested JS object representation of it. |
|
public |
Define the maximum number of elements to return (useful for pagination). |
|
public |
Populate the joins for a collection or association of the primary model of the query. |
|
public |
Define the number of elements to skip (useful for pagination). |
|
public |
Define the ordering of the results |
|
public |
Define a restriction on the result set. |
Public Constructors
public constructor(modelId: String, models: JoinJsMap, knex: KnexInstance) source
Generally, this shouldn't be called by external code. This object is generated by the main
interface when the generateQueryFor
method is used.
Params:
Name | Type | Attribute | Description |
modelId | String | The |
|
models | JoinJsMap | The complete schema of the database (after internal processing) |
|
knex | KnexInstance | A knex instance |
Public Members
public knex: * source
public modelId: * source
public models: * source
public originalModel: * source
public populated: *[] source
public sortAttr: * source
public sortDir: * source
public whereClauses: *[] source
Public Methods
public limit(value: Number): * source
Define the maximum number of elements to return (useful for pagination).
Params:
Name | Type | Attribute | Description |
value | Number | The maximum number of elements to return |
Return:
* |
public populate(name: String): * source
Populate the joins for a collection or association of the primary model of the query.
Params:
Name | Type | Attribute | Description |
name | String | The name property of the association or collection |
Return:
* |
public skip(value: Number): * source
Define the number of elements to skip (useful for pagination).
Params:
Name | Type | Attribute | Description |
value | Number | The number of elements to skip |
Return:
* |
public where(clauses: Object | Array): * source
Define a restriction on the result set.
Params:
Name | Type | Attribute | Description |
clauses | Object | Array | An object (or list of objects) specifying the predicate that all results must satisfy. Multiple calls to this function on a single prepared query instance will be appended to the list of clauses that are combined using boolean AND logic (ie. results must satisfy all predicates in the list)
|
Return:
* |