The Spell class.
Methods
(inner) checkCond(Model, conds)
check condition to avoid use virtual fields as where conditions
Parameters:
| Name | Type | Description |
|---|---|---|
Model |
||
conds |
(inner) findAssociation(associations, opts)
Find association by certain criteria.
Parameters:
| Name | Type | Description |
|---|---|---|
associations |
Model associations |
|
opts |
Model
|
Search criteria, e.g. |
Example:
findAssociation({ Model: Post });
(inner) formatValueSet(spell, obj, strict)
Translate key-value pairs of columnAttributes into key-value pairs of columns. Get ready for the SET part when generating SQL.
Parameters:
| Name | Type | Description |
|---|---|---|
spell |
||
obj |
key-value pairs of columnAttributes |
|
strict |
check attribute exist or not |
(inner) joinAssociation(spell, BaseModel, baseName, refName, opts)
Parse associations into spell.joins
Parameters:
| Name | Type | Description |
|---|---|---|
spell |
An instance of spell |
|
BaseModel |
A subclass of Bone |
|
baseName |
Might be Model.tableAlias, Model.table, or other names given by users |
|
refName |
The name of the join target |
|
opts |
Extra options such as |
(inner) joinOnConditions(spell, BaseModel, baseName, refName, opts)
Construct on conditions as ast from associations.
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
spell |
|||||||||||
BaseModel |
|||||||||||
baseName |
|||||||||||
refName |
|||||||||||
opts |
|
Example:
joinOnConditions(spell, Post, 'posts', 'comments', {
association: { Model: Comment, foreignKey: 'postId' }
});
(inner) parseConditions(Model, conditions, …values)
Parse condition expressions
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
Model |
|||
conditions |
|||
values |
<repeatable> |
Example:
parseConditions(Model, { foo: { $op: value } });
parseConditions(Model, 'foo = ?', value);
(inner) parseSet(spell, obj)
Translate key-value pairs of columnAttributes into key-value pairs of columns. Get ready for the SET part when generating SQL.
Parameters:
| Name | Type | Description |
|---|---|---|
spell |
||
obj |
key-value pairs of columnAttributes |
(inner) scopeDeletedAt()
If Model supports soft delete, and deletedAt isn't specified in whereConditions yet, and the table isn't a subquery, append a default where({ deletedAt: null }).