Methods
BelongsTo()
design:type will be Function { [native code] } in following example
Example:
import type Foo from './foo';
class Bar extends Bone {
collectLiteral(values, ast)
The ... IS NULL predicate is not parameterizable.
- https://github.com/brianc/node-postgres/issues/1751
Parameters:
| Name | Type | Description |
|---|---|---|
values |
the collected values |
|
ast |
the abstract syntax tree |
executeValidator(ctx, name, attribute, setValue)
Execute a validator on a Bone instance
Parameters:
| Name | Type | Description |
|---|---|---|
ctx |
context |
|
name |
validate name |
|
attribute |
||
setValue |
findModel(spell, qualifiers)
Find model by qualifiers.
Parameters:
| Name | Type | Description |
|---|---|---|
spell |
||
qualifiers |
Example:
findModel(spell, ['comments'])
findModel(spell)
formatArgs(isInstance, fnName, args, target)
Parameters:
| Name | Type | Description |
|---|---|---|
isInstance |
class or instance |
|
fnName |
||
args |
||
target |
class or instance } |
formatConditions(conditions)
Format an array of conditions into an expression. Conditions will be joined with AND.
Parameters:
| Name | Type | Description |
|---|---|---|
conditions |
An array of parsed where/having/on conditions |
formatExpr(spell, ast)
Format the abstract syntax tree of an expression into escaped string.
Parameters:
| Name | Type | Description |
|---|---|---|
spell |
||
ast |
formatIdentifier(spell, ast)
Format identifiers into escaped string with qualifiers.
Parameters:
| Name | Type | Description |
|---|---|---|
spell |
||
ast |
formatOpExpr(spell, ast)
Format { type: 'op' } expressions into escaped string.
Parameters:
| Name | Type | Description |
|---|---|---|
spell |
||
ast |
instantiatable(spell)
Check if the query result of spell is instantiatable by examining the query structure.
- https://www.yuque.com/leoric/blog/ciiard#XoI4O (zh-CN)
Parameters:
| Name | Type | Description |
|---|---|---|
spell |
isAggregatorExpr()
Format the abstract syntax tree of an expression into escaped string.
isLogicalCondition(condition)
determine if query object is logical condition
Parameters:
| Name | Type | Description |
|---|---|---|
condition |
query object |
isLogicalOp()
Check if current token is logical operator or not, e.g. AND/NOT/OR.
isLogicalOperator(operator)
determin if operator is logical operator
Parameters:
| Name | Type | Description |
|---|---|---|
operator |
lowercased operator |
isOperatorCondition()
Check if object condition is an operator condition, such as { $gte: 100, $lt: 200 }.
parseLogicalOperator($op, value)
parse logical objects that is already in tree-like structure
Parameters:
| Name | Type | Description |
|---|---|---|
$op |
logical operators, such as |
|
value |
logical operands |
Example:
{ $or: { title: 'Leah', content: 'Diablo' } }
{ $or: [ { title: 'Leah' }, { content: 'Diablo' } ] }
{ $not: [ { title: 'Leah' }, { title: { $like: '%jjj' }} ] }
parseNamedLogicalOperator(name, condition)
parse logical objects that have column name lifted upper level
Parameters:
| Name | Type | Description |
|---|---|---|
name |
column name |
|
condition |
logical query objects |
Example:
{ foo: { $not: { $gt: '2021-01-01', $lte: '2021-12-31' } } }
{ foo: { $not: [ '2021-09-30', { $gte: '2021-10-07' } ] } }
{ foo: { $not: [ 'Leah', 'Nephalem' ] } }
parseObject()
Parse query objects, which is a complete madness because the operator orders vary. The result would be normalized spell ast. See module:src/query_object~OPERATOR_MAP and module:src/query_object~LOGICAL_OPERATOR_MAP for supported $ops.
Example:
{ foo: null }
{ foo: { $gt: new Date(2012, 4, 15) } }
{ foo: { $between: [1, 10] } }
{ foo: { $or: [ 'Leah', { $like: '%Leah%' } ] } }
{ foo: [ 1, 2, 3 ] }
{ foo: { $not: { $gt: '2021-01-01', $lte: '2021-12-31' } } }
{ foo: { $not: [ '2021-09-30', { $gte: '2021-10-07' } ] } }
{ foo: { $not: [ 'Leah', 'Nephalem' ] } }
{ $or: { title: 'Leah', content: 'Diablo' } }
{ $or: [ { title: 'Leah', content: 'Diablo' }, { title: 'Stranger' } ] }
parseOperator(name)
parse operator condition into expression ast
Parameters:
| Name | Type | Description |
|---|---|---|
name |
Example:
parseOperator('id', { $gt: 0, $lt: 999999 });
// => { type: 'op', name: 'and', args: [ ... ]}
parseValue()
Parse object values as literal or subquery
(async) rawQuery()
raw query
setupSingleHook(target, hookName, func)
setup hook to class
Parameters:
| Name | Type | Description |
|---|---|---|
target |
target class |
|
hookName |
||
func |