The Spell
class.
Methods
(inner) findAssociation(associations, opts)
Find association by certain criteria.
Parameters:
Name | Type | Description |
---|---|---|
associations |
Object
|
Model associations |
opts |
Object
|
Search criteria, e.g. { Model } |
Example:
findAssociation({ Model: Post });
(inner) formatValueSet(spell, obj, strict) → {Object}
Translate key-value pairs of attributes into key-value pairs of columns. Get ready for the SET part when generating SQL.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
spell |
Spell
|
||
obj |
Object
|
key-value pairs of attributes |
|
strict |
boolean
|
true |
check attribute exist or not |
Returns:
- Type:
-
Object
(inner) joinAssociation(spell, BaseModel, baseName, refName, opts)
Parse associations into spell.joins
Parameters:
Name | Type | Description |
---|---|---|
spell |
Spell
|
An instance of spell |
BaseModel |
Model
|
A subclass of Bone |
baseName |
string
|
Might be Model.tableAlias, Model.table, or other names given by users |
refName |
string
|
The name of the join target |
opts |
Object
|
Extra options such as { select, throughAssociation } |
(inner) joinOnConditions(spell, BaseModel, baseName, refName, opts)
Construct on conditions as ast from associations.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
spell |
Spell
|
||||||||||
BaseModel |
Model
|
||||||||||
baseName |
string
|
||||||||||
refName |
string
|
||||||||||
opts |
Object
|
|
Example:
joinOnConditions(spell, Post, 'posts', 'comments', {
association: { Model: Comment, foreignKey: 'postId' }
});
(inner) parseConditions(conditions, …values) → {Array}
Parse condition expressions
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
conditions |
string
|
Object
|
||
values |
*
|
<repeatable> |
Returns:
- Type:
-
Array
Example:
parseConditions({ foo: { $op: value } });
parseConditions('foo = ?', value);
(inner) parseSet(spell, obj)
Translate key-value pairs of attributes into key-value pairs of columns. Get ready for the SET part when generating SQL.
Parameters:
Name | Type | Description |
---|---|---|
spell |
Spell
|
|
obj |
Object
|
Array
|
key-value pairs of attributes |
(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 }).