Members
(constant) INDEX_HINT_SCOPE
Properties:
Name | Type | Description |
---|---|---|
join |
||
orderBy |
||
groupBy |
(constant) INDEX_HINT_TYPE
Properties:
Name | Type | Description |
---|---|---|
use |
||
force |
||
ignore |
Methods
collectLiteral(values, ast) → {Array}
The ... IS NULL
predicate is not parameterizable.
- https://github.com/brianc/node-postgres/issues/1751
Parameters:
Name | Type | Description |
---|---|---|
values |
Array
|
the collected values |
ast |
Object
|
the abstract syntax tree |
Returns:
- Type:
-
Array
values
executeValidator(ctx, name, attribute, value)
Parameters:
Name | Type | Description |
---|---|---|
ctx |
Bone
|
context |
name |
string
|
validate name |
attribute |
object
|
|
value |
*
|
findModel(spell, qualifiers)
Find model by qualifiers.
Parameters:
Name | Type | Description |
---|---|---|
spell |
Spell
|
|
qualifiers |
Array.<string>
|
Example:
findModel(spell, ['comments'])
findModel(spell)
(async) findModels(dir) → {Array.<Bone>}
find models in directory
Parameters:
Name | Type | Description |
---|---|---|
dir |
string
|
Returns:
- Type:
-
Array.<Bone>
formatArgs(isInstance, fnName, args, target) → {FormatResult}
Parameters:
Name | Type | Description |
---|---|---|
isInstance |
boolean
|
class or instance |
fnName |
string
|
|
args |
array
|
|
target |
Bone
|
class or instance |
formatConditions(conditions)
Format an array of conditions into an expression. Conditions will be joined with AND
.
Parameters:
Name | Type | Description |
---|---|---|
conditions |
Array.<Object>
|
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 |
Spell
|
|
ast |
Object
|
formatIdentifier(spell, ast)
Format identifiers into escaped string with qualifiers.
Parameters:
Name | Type | Description |
---|---|---|
spell |
Spell
|
|
ast |
Object
|
formatOpExpr(spell, ast)
Format { type: 'op' }
expressions into escaped string.
Parameters:
Name | Type | Description |
---|---|---|
spell |
Spell
|
|
ast |
Object
|
instantiatable(spell) → {boolean}
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 |
Spell
|
Returns:
- Type:
-
boolean
isLogicalCondition(condition) → {boolean}
determine if query object is logical condition
Parameters:
Name | Type | Description |
---|---|---|
condition |
Object
|
query object |
Returns:
- Type:
-
boolean
isLogicalOp(ast)
Check if current token is logical operator or not, e.g. AND
/NOT
/OR
.
Parameters:
Name | Type | Description |
---|---|---|
ast |
Object
|
isLogicalOperator(operator) → {boolean}
determin if operator is logical operator
Parameters:
Name | Type | Description |
---|---|---|
operator |
string
|
lowercased operator |
Returns:
- Type:
-
boolean
isOperatorCondition(condition) → {boolean}
Check if object condition is an operator condition, such as { $gte: 100, $lt: 200 }
.
Parameters:
Name | Type | Description |
---|---|---|
condition |
Object
|
Returns:
- Type:
-
boolean
parseLogicalOperator($op, value)
parse logical objects that is already in tree-like structure
Parameters:
Name | Type | Description |
---|---|---|
$op |
string
|
logical operators, such as |
value |
Object
|
Array.<Object>
|
logical operands |
Example:
{ $or: { title: 'Leah', content: 'Diablo' } }
{ $or: [ { title: 'Leah' }, { content: 'Diablo' } ] }
{ $not: [ { title: 'Leah' }, { title: { $like: '%jjj' }} ] }
parseNamedLogicalOperator(name, condition) → {Object}
parse logical objects that have column name lifted upper level
Parameters:
Name | Type | Description |
---|---|---|
name |
string
|
column name |
condition |
Object
|
logical query objects |
Returns:
- Type:
-
Object
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(conditions)
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 $op
s.
Parameters:
Name | Type | Description |
---|---|---|
conditions |
Object
|
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, condition) → {Object}
parse operator condition into expression ast
Parameters:
Name | Type | Description |
---|---|---|
name |
string
|
|
condition |
Object
|
Returns:
- Type:
-
Object
Example:
parseOperator('id', { $gt: 0, $lt: 999999 });
// => { type: 'op', name: 'and', args: [ ... ]}
parseValue(value) → {Array.<Object>}
Parse object values as literal or subquery
Parameters:
Name | Type | Description |
---|---|---|
value |
Object
|
Returns:
- Type:
-
Array.<Object>
setupSingleHook(target, hookName, func)
setup hook to class
Parameters:
Name | Type | Description |
---|---|---|
target |
Bone
|
target class |
hookName |
string
|
|
func |
function
|
Type Definitions
FormatResult
Properties:
Name | Type | Description |
---|---|---|
useHooks |
boolean
|
|
args |
Array
|
QueryResult
Properties:
Name | Type | Description |
---|---|---|
rows |
Array
|
|
fields |
Array
|
RawSql
Properties:
Name | Type | Description |
---|---|---|
__raw |
boolean
|
|
value |
string
|
|
type |
string
|