-
Notifications
You must be signed in to change notification settings - Fork 0
ModelScope
class ModelScope extends QueryEngineBase 📜
ModelScope is the "model level" of a query.
It manages things like EXISTS, PROJECT,
ORDER, INNER_JOIN, etc...
Being a Proxy, it will "listen" for key access, and lookup fields if there is a key access where the key name isn't found on the class instance itself. In this case, it will check the previous model specified on the top of the internal "operation stack" to see if it owns a field with the name of the missing key. If there is a matching field on the top-most model of the stack, then it will use the field found to push a FieldScope onto the "operation stack", and then return that to the user. Take the following example:
let queryRoot = new QueryEngine({ connection });
let userIDFieldScope = queryRoot.User.id;When we attempt to access the key 'id' on
the User "model scope", we will find that no such key
exists on the ModelScope class. Now that no such property is found
on the ModelScope class, the ProxyClass will call the method
MISSING on the ModelScope, and this MISSING method
will check if the current model (User) has a field named 'id'.
The ModelScope._getField method finds this field, and
returns it. The ModelScope then takes this field instance,
and uses it to create and return a FieldScope
using QueryEngineBase._newFieldScope. Now
that we have a FieldScope, we can continue
chaining, now using "field level" operators to act on
the field we just looked up.
Notes:
-
ModelScopeis a sub-part of theQueryEngine, and so is generally referred to simply as theQueryEngineas a whole. This is also the case for QueryEngineBase, and FieldScope, which also make up theQueryEngineas sub-parts, and so are also often referred to simply as "the query engine".
See also: QueryEngineBase, QueryEngine, FieldScope
Get the specified field (by name) from the top-most model on the internal "operation stack".
This method is called when a key can not be found
on the ModelScope instance. The ProxyClass
will call the MISSING method when the key is not
found, and that method in turn calls this _getField
method to see if the key specified was actually a field
name on the most recent model in the "operation stack".
Arguments:
-
fieldName:stringThe field name of the field to fetch from the top-most model on the stack.
Return value: Field
The field found, or undefined if no such field is found.
method ModelScope::AND(
query?: QueryEngine,
): ModelScope 📜
Logical AND, for ANDing operations together.
This method does not need to be called, but it can be called if desired.
This is a "toggle", so as soon as it is used,
it will continue to be "active" for all following
operations. In Mythix ORM you don't need to specify
AND or OR unless you actually need them. By default
AND is enabled for all queries. So for example you
can do User.where.id.EQ('test').firstName.EQ('John').lastName.EQ('Smith'),
which is exactly the same as User.where.id.EQ('test').AND.firstName.EQ('John').AND.lastName.EQ('Smith').
AND can also be called to group conditions. For example, you could create
the following query: User.where.id.EQ('test').AND(User.where.lastName.EQ('John').OR.lastName.EQ('Brown'))
to create the following SQL query: WHERE id = 'test' AND (lastName = 'John' OR lastName = 'Brown').
Arguments:
-
query?: QueryEngineAn optional query, which if provided, will create a "condition group" as a result.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::CROSS_JOIN(): ModelScope 📜
Specify a CROSS JOIN operation for joining tables.
This method does not need to be called.
All Mythix ORM "join" operations should come immediately
before a table join. For example: User.where.CROSS_JOIN.id.EQ(Role.where.userID).
They are "toggles", and so will remain "on" once used. In short, if
you specify a CROSS_JOIN at the very beginning of your query, then
ALL table joins in the query will be CROSS JOIN, unless you specify
other join types, i.e. User.where.CROSS_JOIN.id.EQ(Role.where.userID).AND.INNER_JOIN.id.EQ(Organization.where.userID).
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::DISTINCT(
field?: Field | LiteralBase | string | false = Model.getPrimaryKeyField(),
): ModelScope 📜
Apply a DISTINCT clause to the query.
This method does not need to be called, but it can be called if desired.
A field is required for this operation to keep the interface consistent across all database drivers... however, the field specified may not actually be used, depending on database support, or other operations being carried out in the query.
If the underlying database supports it (i.e. PostgreSQL), then
this will turn into a DISTINCT ON(field) operation. If the
database (or operation being carried out), doesn't support DISTINCT ON,
then it will fallback to just a DISTINCT across the entire projection.
Any DISTINCT operation applied to the query will always be the very
first part of the projection, regardless of whatever else is projected.
This method is optionally callable. If not called, then the primary key
of the model specified will be used (if available). If no primary key exists
on the specified model, then it will fallback to a raw DISTINCT clause
prefixing the projection. For example: User.where.DISTINCT.lastName.EQ('Smith')
would be distinct on the primary key of User (which would be id in our example).
If instead we call the operator, then we can supply our own field or literal:
User.where.DISTINCT('User:firstName').lastName.EQ('Smith').
To turn off any previous DISTINCT applied, pass the argument false to
DISTINCT: User.where.DISTINCT.lastName.EQ('Smith').DISTINCT(false).
In this example the resulting query would have no DISTINCT clause at all,
since it was disabled when DISTINCT(false) was called.
DISTINCT changes the nature of the query, and might change how it is carried out
by the underlying database driver. For example, a distinct combined with a count
call would modify the count query: await User.where.DISTINCT('User:id').count() would
actually turn into the following SQL: SELECT COUNT(DISTINCT "users"."id"). This
is just one example however... just know that the underlying database driver might
alter the query, or take a completely different path to query if a DISTINCT operation
is in-play.
Notes:
- The support for a
DISTINCTclause changes wildly across databases. Some might supportONfor a specific column, some may not. Some databases might force a certainORDERwhen usingDISTINCT, some may not...DISTINCTmay be supported in sub-queries, or it may not... or might require the query be written differently. Mythix ORM does its best to make a "standard" out of this very non-standard situation (does any SQL actually follow a standard?), but just be aware thatDISTINCTmight bite you if you are changing database drivers to a database that behaves differently.
Arguments:
-
field?: Field | LiteralBase |string|false(Default:Model.getPrimaryKeyField())The field or literal to be
DISTINCT ON(if the database supports it). Iffalseis specified, then any previousDISTINCToperation is cleared.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::EXISTS(
query: QueryEngine,
): ModelScope 📜
Check if any rows match the query provided.
This is on the ModelScope itself because it is never paired with a field, and is an operator that stands all on its own.
It can be used to check the existence of any value in the
database. For example, you might want to query on users,
but only if those users have an "admin" role:
await User.where.email.EQ('test@example.com').EXISTS(Role.where.name.EQ("admin").userID.EQ(new FieldLiteral('User:id')))
Notes:
- You can execute a
NOT EXISTSoperation simply by prefixingEXISTSwith a.NOToperation, for examplequery.NOT.EXISTS(...).
Arguments:
-
query: QueryEngineThe sub-query to execute to check for existence. Use a FieldLiteral to pair it with the primary query.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::Field(
fieldName: string,
): FieldScope 📜
Specify a FieldScope directly.
This can be useful if you have a name collision, or if you just want to go the direct route to specify a FieldScope.
This will find the field specified on the most recent (top-most) model on the internal "operation stack". If the field is found, then it will be used to create a new FieldScope, which will then be pushed onto the "operation stack", and returned to the user.
Example:
-
// The two queries below are equivalent. The latter // can be a good way to request a field if the field // name being specified happens to be a name collision // (i.e. has the same name as a QueryEngine or ModelScope // property... such as "ORDER" or "OFFSET" for example). let query1 = User.where.id.EQ('test'); let query2 = User.where.Field('id').EQ('test');
Notes:
- An exception will be thrown in the specified field can not be found.
- This is one of the rare places in Mythix ORM where a fully qualified field name SHOULD NOT be used. The reason should be clear: The model in the operation should already be known.
Arguments:
-
fieldName:stringA field name (NOT fully qualified), as a string. It must be a field that exists on the model from the top-most ModelScope on the internal "operation stack".
Return value: FieldScope
A new FieldScope, targeted to the field specified by fieldName.
method ModelScope::FULL_JOIN(
outerJoin?: boolean = false,
): ModelScope 📜
Specify a FULL JOIN operation for joining tables.
This method does not need to be called, but it can be called if desired.
All Mythix ORM "join" operations should come immediately
before a table join. For example: User.where.FULL_JOIN.id.EQ(Role.where.userID).
They are "toggles", and so will remain "on" once used. In short, if
you specify a FULL_JOIN at the very beginning of your query, then
ALL table joins in the query will be FULL JOIN, unless you specify
other join types, i.e. User.where.FULL_JOIN.id.EQ(Role.where.userID).AND.INNER_JOIN.id.EQ(Organization.where.userID).
Arguments:
-
outerJoin?:boolean(Default:false)If
true, then this will result in aFULL OUTER JOINif the database supports it.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::GROUP_BY(
...args: Array<Field | LiteralBase | string | '+' | '-' | '*'>,
): ModelScope 📜
Apply a GROUP BY clause to the query.
See ModelScope.mergeFields to better understand how this method works.
Notes:
- This method will flatten all provided arguments into a one dimensional array, so you can provide arrays or deeply nested arrays for the fields specified.
Arguments:
-
...args: Array<Field | LiteralBase |string|'+'|'-'|'*'>New "fields" to supply to
GROUP BY, replacing, adding, or subtracting the specified fields from theGROUP_BYoperation.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::HAVING(
query: QueryEngine,
): ModelScope 📜
Apply a HAVING clause to the query.
This will only be applied in the underlying database query if it is also paired with a ModelScope.GROUP_BY operation, otherwise it will be ignored.
Example:
-
let adultCountByAge = await User.where .GROUP_BY('User:age') .HAVING(User.where.age.GTE(18)) .PROJECT('User:age', new CountLiteral('User:age', { as: 'count' })) .all();
Arguments:
-
query: QueryEngineThe query to use to apply conditions to the
HAVINGclause.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::INNER_JOIN(): ModelScope 📜
Specify an INNER JOIN operation for joining tables.
This method does not need to be called, but it can be called if desired.
All Mythix ORM "join" operations should come immediately
before a table join. For example: User.where.INNER_JOIN.id.EQ(Role.where.userID).
They are "toggles", and so will remain "on" once used. In short, if
you specify an INNER_JOIN at the very beginning of your query, then
ALL table joins in the query will be INNER JOIN, unless you specify
other join types.
Notes:
-
INNER_JOINis the default table join type in Mythix ORM if no other table join type is specified in the query.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::JOIN(
type: Literal | string,
): ModelScope 📜
Specify a custom join operation for the underlying database. It is recommended that you use a literal, though that isn't required.
All Mythix ORM "join" operations should come immediately
before a table join. For example: User.where.JOIN('RIGHT INNER JOIN').id.EQ(Role.where.userID).
They are "toggles", and so will remain "on" once used.
Notes:
- This method should be avoided if at all possible, since it will likely be database specific, making your code not as portable to another database driver.
- Is there a standard join type that Mythix ORM missed, that should be supported across most or all databases? If so, let us know by opening an Issue or PR on our GitHub page. Thank you!
Arguments:
-
type: Literal |stringThe join type to use in the underlying database (a literal value).
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::LEFT_JOIN(
outerJoin?: boolean = false,
): ModelScope 📜
Specify a LEFT JOIN operation for joining tables.
This method does not need to be called, but it can be called if desired.
All Mythix ORM "join" operations should come immediately
before a table join. For example: User.where.LEFT_JOIN.id.EQ(Role.where.userID).
They are "toggles", and so will remain "on" once used. In short, if
you specify a LEFT_JOIN at the very beginning of your query, then
ALL table joins in the query will be LEFT JOIN, unless you specify
other join types, i.e. User.where.LEFT_JOIN.id.EQ(Role.where.userID).AND.INNER_JOIN.id.EQ(Organization.where.userID).
Arguments:
-
outerJoin?:boolean(Default:false)If
true, then this will result in aLEFT OUTER JOINif the database supports it.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::LIMIT(
limit: number,
): ModelScope 📜
Apply a LIMIT clause to the query.
Any valid positive integer is acceptable, as well as Infinity.
If Infinity is used, then the LIMIT will either turn into its
max possible value (in the billions... depending on the underlying database),
or it will be stripped from the query entirely.
NaN, or anything that isn't a valid positive integer will throw an error.
Notes:
- Positive floating point numbers are rounded with
Math.round.
Arguments:
-
limit:numberThe limit to apply to the query.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::mergeFields(
currentFields: Map<string, { value: Field | Literal | string; direction?: '+' | '-'; ... }>,
incomingFields: Array<Model | Field | string | literal | '+' | '-' | '*'>,
extraData?: object,
options?: object,
): Map<string, { value: Field | Literal | string; direction?: '+' | '-'; ... }> 📜
Merge fields together, replacing, adding, or subtracting from the field set.
This method is used by ModelScope.ORDER, ModelScope.GROUP_BY, and ModelScope.PROJECT. It works be replacing, adding, or subtracting from the current set of fields defined by any of these operations.
If the first field encountered in the provided incomingFields isn't prefixed with
a + or -, and if a + or - operation doesn't come before the encountered field, then
the operation is considered a "replace" operation. For example, in query.ORDER('User:id')
we are "replacing" the order clause with only a single field: 'User:id'. If however,
we did query.ORDER('+User:id') then the 'User:id' field would be added to any current
order clause in the query. We could also prefix the entire operation with a single '+'
string, and then all following fields in the list would be in "add" mode. For example, the
following two operations are equivalent: query.ORDER('+', 'User:firstName', 'User:lastName'), and
query.ORDER('+User:firstName', '+User:lastName'). The subtraction operator '-' works the
same, but in reverse, specifying that we want to remove fields instead of add them:
query.ORDER('-', 'User:firstName', 'User:lastName'), and query.ORDER('-User:firstName', '-User:lastName').
It is also possible to mix the two together: query.ORDER('+', 'User:firstName', '-', 'User:lastName'), or
query.ORDER('+User:firstName', '-User:lastName').
There is one special operator, '*'. This operator will add all fields from all models that
are currently in use on the query. For example, if we did: Role.where.userID(User.where.id).PROJECT('*'),
this would add all Role and User fields to the projection. Replace, add, and subtract rules still
apply with a wildcard. So in our example above we are "replacing" the projection, since no + or - was
encountered before the operation. If you instead wanted to add all model fields to the projection,
you should instead do: Role.where.userID(User.where.id).PROJECT('+*') or Role.where.userID(User.where.id).PROJECT('+', '*').
Generally, it probably wouldn't matter much, since you are replacing "every field" anyhow... but it could
matter if for example you had previously projected a literal... in which case it would be replaced
with all model fields. Subtraction rules also apply to wildcard selectors.
The only truly important thing to remember here is that if no operation is specified (add or subtract), then the default operation is "replace", so the field set will be replaced entirely for the operation in question.
There is one exception to this behavior, for ORDER.ADD and ORDER.REPLACE only. These two operations
allow the field sort direction itself to be defined with + and -... so a
query.ORDER.ADD('+User:firstName', '-User:lastName') is not requesting that we add the 'User:firstName'
field, and subtract the 'User:lastName' field... but instead is specifying that we want
'User:firstName' in ASC sort order, whereas we want 'User:lastName' in DESC sort order.
ORDER.ADD and ORDER.REPLACE are the only exceptions to the normal logic defined here. There are
two methods so that a user can add to the field set, or replace the field set. A SUB (subtract)
operation is not needed, because that can be done with ORDER anyway, i.e.
query.ORDER.ADD('+User:firstName', '+User:lastName').ORDER('-Role'), which would "add" the
'User:firstName' and 'User:lastName' fields, simultaneously specifying their short direction,
and then ORDER('-Role') is subtracting every field from the Role model.
Notes:
- A solo
+or-operation is a no-op:query.ORDER('+')andquery.ORDER('-')will do nothing at all, and will not modify the operation in the slightest. - This method supports a short-cut for literals. You can specify a string prefixed
with an
@symbol to specify a literal. For example,query.PROJECT('@COUNT("users"."firstName") AS "count"'). Doing so will create a new Literal instance with the value provided. This is not the best way to provide a literal however, because the Literal class defines a "raw" literal, whereas the typed literal classes (such as CountLiteral) actually store the field they are operating on, and can report that field back to the engine.
Arguments:
-
currentFields:Map<string, { value: Field | Literal | string; direction?: '+' | '-'; ... }>A map of the current fields for the operation. This is the value from the operation context itself. For example, the
ORDERmethod provides this argument via:this.getOperationContext().order, providing any previous "order" operation as the current fields. -
incomingFields: Array<Model | Field |string|literal|'+'|'-'|'*'>Incoming fields to replace, add, or subtract from the operation in question. If no fields at all are provided, then this will reset/nullify the operation. For example, an
ORDER()would clear anyORDER BYclause entirely. If a model is provided, either as a name, i.e.'User', or as the raw model, i.e.User, then all the fields from the specified model will be added or subtracted. A field can be specified as a fully qualified field name, a raw Field instance, or just the field name itself, i.e.'firstName'. If no model is specified (i.e. a non-fully-qualified field name), then the engine will attempt to fetch the field specified from the root model of the query. Literals can be used for all supported operations,ORDER,GROUP_BY, andPROJECT, and they also follow the replace, add and subtract rules of the engine. -
extraData?:objectExtra data to apply to the operation. For example, the
ORDERoperation applies adirectionproperty to each field in the map. The field map is aMapinstance, where each key is the fully qualified field name, or expanded literal value. Each value on the map is an object, containing at least avalueproperty that is the field or literal specified. This object can also contain any ancillary operation info, such as in the case of theORDERoperation, which will also add adirectionproperty to each field in the map to specify the field's (or literal's) sort order. -
options?:objectAn options object to pass off to
Literal.toStringwhen expanding literals for use asMapkeys.
Return value: Map<string, { value: Field | Literal | string; direction?: '+' | '-'; ... }>
Return the new field set. A Map will always be returned, but it is possible
for the Map to be empty.
method ModelScope::NOT(): ModelScope 📜
Invert the logic of the following operator.
This method does not need to be called.
Unlike AND and OR operators, this is not a permanent toggle.
As soon as a following operator is encountered, the NOT operation
will be "turned off". NOT will invert any operation, so for example
if you did a User.where.id.NOT.EQ('test') then this is the same as
User.where.id.NEQ('test')--selecting everything NOT EQUAL TO 'test'.
NOT can also be used in combination with EXISTS, ANY, ALL, IN,
etc... inverting any operator following NOT.
Notes:
-
NOTis only ever used once, and then it is toggled back off. For example, if we did:User.where.id.NOT.EQ('test').AND.lastName.EQ('Smith'), then we would have a query whereid != 'test' AND lastName = 'Smith'. As you can see, theNOTdoesn't apply to the secondlastNameoperator, as it was turned off as soon as the firstEQoperator was encountered on theidfield.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::OFFSET(
offset: number,
): ModelScope 📜
Apply an OFFSET clause to the query.
Any valid positive integer is acceptable. Infinity, NaN,
or anything that isn't a valid positive integer will throw an error.
Notes:
- Positive floating point numbers are rounded with
Math.round.
Arguments:
-
offset:numberThe offset to apply to the query.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::OR(
query?: QueryEngine,
): ModelScope 📜
Logical OR, for ORing operations together.
This method does not need to be called, but it can be called if desired.
This is a "toggle", so as soon as it is used,
it will continue to be "active" for all following
operations. In Mythix ORM you don't need to specify
AND or OR unless you actually need them. By default
AND is enabled for all queries. For example you
can do User.where.id.EQ('test').OR.firstName.EQ('John').lastName.EQ('Smith'),
which is exactly the same as User.where.id.EQ('test').OR.firstName.EQ('John').OR.lastName.EQ('Smith').
OR can also be called to group conditions. For example, you could create
the following query: User.where.id.EQ('test').OR(User.where.firstName.EQ('John').OR.lastName.EQ('Brown'))
to create the following SQL query: WHERE id = 'test' OR (firstName = 'John' AND lastName = 'Brown').
Arguments:
-
query?: QueryEngineAn optional query, which if provided, will create a "condition group" as a result.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::ORDER(
...args: Array<Field | LiteralBase | string | '+' | '-' | '*'>,
): ModelScope 📜
Apply an ORDER BY clause to the query, to sort
the results on the fields specified, in either
ASC or DESC order.
There are five variants to this method, ORDER.ASC,
ORDER.DESC, ORDER.ADD, ORDER.REPLACE, and ORDER (which is an alias for ORDER.ASC), .
-
ORDER- Alias forORDER.ASC. -
ORDER.ASC- Follow the rules of ModelScope.mergeFields. Each field/literal added is inASCorder. -
ORDER.DESC- Follow the rules of ModelScope.mergeFields. Each field/literal added is inDESCorder. -
ORDER.ADD- DO NOT follow the rules of ModelScope.mergeFields, and instead add all fields specified, with their sort order being specified instead by the+or-prefixes on each field. -
ORDER.REPLACE- DO NOT follow the rules of ModelScope.mergeFields, and instead replace the operation fields to the fields specified, with their sort order being specified instead by the+or-prefixes on each field.
See ModelScope.mergeFields to better understand how this method works.
Notes:
- This method will flatten all provided arguments into a one dimensional array, so you can provide arrays or deeply nested arrays for the fields specified.
Arguments:
-
...args: Array<Field | LiteralBase |string|'+'|'-'|'*'>New "fields" to supply to
ORDER, replacing, adding, or subtracting the specified fields from theORDERoperation.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::PROJECT(
...args: Array<Field | LiteralBase | string | '+' | '-' | '*'>,
): ModelScope 📜
Replace, add to, or subtract from the projection of the query.
See ModelScope.mergeFields to better understand how this method works.
Notes:
- This method will flatten all provided arguments into a one dimensional array, so you can provide arrays or deeply nested arrays for the fields specified.
- Mythix ORM collects and returns models (or partial models) based on the projection. By default only the "root model" of a query will be projected and converted into model instances. If you want to fetch more than just the root model while querying, make sure to project the models (or fields from other models) that you want to collect into model instances during load.
Arguments:
-
...args: Array<Field | LiteralBase |string|'+'|'-'|'*'>New "fields" to supply to the projection, replacing, adding, or subtracting the specified fields from the
PROJECToperation.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
method ModelScope::RIGHT_JOIN(
outerJoin?: boolean = false,
): ModelScope 📜
Specify a RIGHT JOIN operation for joining tables.
This method does not need to be called, but it can be called if desired.
All Mythix ORM "join" operations should come immediately
before a table join. For example: User.where.RIGHT_JOIN.id.EQ(Role.where.userID).
They are "toggles", and so will remain "on" once used. In short, if
you specify a RIGHT_JOIN at the very beginning of your query, then
ALL table joins in the query will be RIGHT JOIN, unless you specify
other join types, i.e. User.where.RIGHT_JOIN.id.EQ(Role.where.userID).AND.INNER_JOIN.id.EQ(Organization.where.userID).
Arguments:
-
outerJoin?:boolean(Default:false)If
true, then this will result in aRIGHT OUTER JOINif the database supports it.
Return value: ModelScope
Return a ModelScope to allow the user to continue chaining operations on the query.
- Associations
- Certifications
- Connection Binding
- Home
- Models
- Queries
- TypeScript
- Types Reference
-
namespace AsyncStore
- function getContextStore
- function getContextValue
- function runInContext
- function setContextValue
-
namespace Helpers
- function checkDefaultValueFlags
- function defaultValueFlags
- function getDefaultValueFlags
- property FLAG_LITERAL
- property FLAG_ON_INITIALIZE
- property FLAG_ON_INSERT
- property FLAG_ON_STORE
- property FLAG_ON_UPDATE
- property FLAG_REMOTE
-
namespace MiscUtils
- function collect
- function valueToDateTime
-
namespace ModelUtils
- function parseQualifiedName
-
namespace QueryUtils
- function generateQueryFromFilter
- function mergeFields
- function parseFilterFieldAndOperator
-
class AverageLiteral
- method static isAggregate
- method toString
-
class BigIntType
- property Default
- method castToType
- method constructor
- method isValidValue
- method static getDisplayName
- method toString
-
class BlobType
- method castToType
- method constructor
- method isValidValue
- method static getDisplayName
- method toString
-
class BooleanType
- method castToType
- method isValidValue
- method static getDisplayName
- method toString
-
class CacheKey
- method constructor
- method valueOf
-
class CharType
- method castToType
- method isValidValue
- method static getDisplayName
- method toString
-
class ConnectionBase
- property _isMythixConnection
- property DefaultQueryGenerator
- property dialect
- property Literals
- method _averageLiteralToString
- method _bigintTypeToString
- method _blobTypeToString
- method _booleanTypeToString
- method _charTypeToString
- method _countLiteralToString
- method _datetimeTypeToString
- method _dateTypeToString
- method _distinctLiteralToString
- method _escape
- method _escapeID
- method _fieldLiteralToString
- method _getFromModelCache
- method _integerTypeToString
- method _maxLiteralToString
- method _minLiteralToString
- method _numericTypeToString
- method _realTypeToString
- method _setToModelCache
- method _stringTypeToString
- method _sumLiteralToString
- method _textTypeToString
- method _uuidV1TypeToString
- method _uuidV3TypeToString
- method _uuidV4TypeToString
- method _uuidV5TypeToString
- method _xidTypeToString
- method addColumn
- method addIndex
- method aggregate
- method alterColumn
- method alterTable
- method average
- method buildConnectionContext
- method bulkModelOperation
- method constructor
- method convertDateToDBTime
- method count
- method createContext
- method createQueryGenerator
- method createTable
- method createTables
- method destroy
- method destroyModels
- method dirtyFieldHelper
- method dropColumn
- method dropIndex
- method dropTable
- method dropTables
- method ensureAllModelsAreInstances
- method escape
- method escapeID
- method exists
- method finalizeQuery
- method findModelField
- method getContextValue
- method getDefaultFieldValue
- method getDefaultOrder
- method getField
- method getLockMode
- method getModel
- method getModels
- method getOptions
- method getQueryEngineClass
- method getQueryGenerator
- method insert
- method isStarted
- method literalToString
- method max
- method min
- method parseQualifiedName
- method pluck
- method prepareAllModelsAndSubModelsForOperation
- method prepareAllModelsForOperation
- method query
- method registerModel
- method registerModels
- method runSaveHooks
- method select
- method setContextValue
- method setPersisted
- method setQueryGenerator
- method splitModelAndSubModels
- method stackAssign
- method start
- method static getLiteralClassByName
- method static isConnection
- method static isConnectionClass
- method static Literal
- method stop
- method sum
- method toQueryEngine
- method transaction
- method truncate
- method typeToString
- method update
- method updateAll
- method upsert
-
class CountLiteral
- method static isAggregate
- method static isFieldRequired
- method toString
-
class DateTimeType
- property Default
- method castToType
- method constructor
- method deserialize
- method isValidValue
- method serialize
- method static getDisplayName
- method toString
-
class DateType
- property Default
- method castToType
- method constructor
- method deserialize
- method isValidValue
- method serialize
- method static getDisplayName
- method toString
-
class DistinctLiteral
- method toString
-
class Field
- property _isMythixField
- property allowNull
- property defaultValue
- property fieldName
- property get
- property index
- property primaryKey
- property set
- property type
- property unique
- property validate
- method clone
- method constructor
- method setModel
- method static isField
- method static isFieldClass
-
class FieldLiteral
- method toString
- class FieldScope
-
class ForeignKeyType
- method castToType
- method constructor
- method getOptions
- method getTargetField
- method getTargetFieldName
- method getTargetModel
- method getTargetModelName
- method initialize
- method isValidValue
- method parseOptionsAndCheckForErrors
- method static getDisplayName
- method static isForeignKey
- method toString
-
class IntegerType
- property Default
- method castToType
- method constructor
- method isValidValue
- method static getDisplayName
- method toString
-
class Literal
- method constructor
-
class LiteralBase
- property _isMythixLiteral
- method constructor
- method definitionToField
- method fullyQualifiedNameToDefinition
- method static isAggregate
- method static isLiteral
- method static isLiteralClass
- method static isLiteralType
- method toString
- method valueOf
-
class LiteralFieldBase
- method constructor
- method getField
- method getFullyQualifiedFieldName
- method static isFieldRequired
- method valueOf
-
class MaxLiteral
- method static isAggregate
- method toString
-
class MinLiteral
- method static isAggregate
- method toString
-
class Model
- property _isMythixModel
- method _castFieldValue
- method _constructField
- method _constructFields
- method _constructor
- method _getConnection
- method _getDirtyFields
- method _getFieldValue
- method _initializeFieldData
- method _initializeModelData
- method _setFieldValue
- method clearDirty
- method constructor
- method destroy
- method getAttributes
- method getConnection
- method getDataValue
- method getDirtyFields
- method getOptions
- method hasValidPrimaryKey
- method isDirty
- method isPersisted
- method onAfterCreate
- method onAfterSave
- method onAfterUpdate
- method onBeforeCreate
- method onBeforeSave
- method onBeforeUpdate
- method onValidate
- method reload
- method save
- method setAttributes
- method setDataValue
- method static _getConnection
- method static all
- method static bindConnection
- method static count
- method static create
- method static cursor
- method static defaultScope
- method static finalizeQuery
- method static first
- method static getConcreteFieldCount
- method static getContextValue
- method static getField
- method static getFields
- method static getForeignKeyFieldsMap
- method static getForeignKeysTargetField
- method static getForeignKeysTargetFieldNames
- method static getForeignKeysTargetModelNames
- method static getForeignKeysTargetModels
- method static getModel
- method static getModelContext
- method static getModelName
- method static getPluralModelName
- method static getPrimaryKeyField
- method static getPrimaryKeyFieldName
- method static getQueryEngine
- method static getQueryEngineClass
- method static getSingularName
- method static getSortedFields
- method static getTableName
- method static getUnscopedQueryEngine
- method static getWhereWithConnection
- method static hasField
- method static hasRemoteFieldValues
- method static initializeFields
- method static isForeignKeyTargetModel
- method static isModel
- method static isModelClass
- method static iterateFields
- method static last
- method static mergeFields
- method static pluck
- method static primaryKeyHasRemoteValue
- method static setContextValue
- method static toString
- method static updateModelContext
- method toJSON
- method toString
- method updateDirtyID
-
class ModelScope
- method _getField
- method AND
- method CROSS_JOIN
- method DISTINCT
- method EXISTS
- method Field
- method FULL_JOIN
- method GROUP_BY
- method HAVING
- method INNER_JOIN
- method JOIN
- method LEFT_JOIN
- method LIMIT
- method mergeFields
- method NOT
- method OFFSET
- method OR
- method ORDER
- method PROJECT
- method RIGHT_JOIN
-
class ModelType
- method fieldNameToOperationName
- method initialize
-
class ModelsType
- method fieldNameToOperationName
- method initialize
-
class NumericType
- method castToType
- method constructor
- method isValidValue
- method static getDisplayName
- method toString
-
class ProxyClass
- property APPLY
- property AUTO_CALL
- property AUTO_CALL_CALLED
- property AUTO_CALL_CALLER
- property CALLABLE
- property CONSTRUCT
- property DEFINE_PROPERTY
- property DELETE_PROPERTY
- property GET
- property GET_OWN_PROPERTY_DESCRIPTOR
- property GET_PROTOTYPEOF
- property HAS
- property IS_EXTENSIBLE
- property MISSING
- property OWN_KEYS
- property PREVENT_EXTENSIONS
- property PROXY
- property SELF
- property SET
- property SET_PROTOTYPEOF
- property shouldSkipProxy
- property TARGET
- method ___autoCall
- method ___call
- method constructor
-
class QueryEngine
- method all
- method average
- method constructor
- method count
- method cursor
- method destroy
- method exists
- method finalizeQuery
- method first
- method getFieldScopeClass
- method getModelScopeClass
- method last
- method max
- method MERGE
- method min
- method Model
- method pluck
- method sum
- method toString
- method unscoped
- method updateAll
-
class QueryEngineBase
- method _fetchScope
- method _inheritContext
- method _newFieldScope
- method _newModelScope
- method _newQueryEngineScope
- method _pushOperationOntoStack
- method clone
- method constructor
- method filter
- method getAllModelsUsedInQuery
- method getConnection
- method getFieldScopeClass
- method getModel
- method getModelScopeClass
- method getOperationContext
- method getOperationStack
- method getQueryEngineClass
- method getQueryEngineScope
- method getQueryEngineScopeClass
- method getQueryID
- method isLastOperationCondition
- method isLastOperationControl
- method isModelUsedInQuery
- method logQueryOperations
- method map
- method queryHasConditions
- method queryHasJoins
- method static generateID
- method static getQueryOperationInfo
- method static isQuery
- method static isQueryOperationContext
- method walk
-
class QueryGeneratorBase
- method _averageLiteralToString
- method _countLiteralToString
- method _distinctLiteralToString
- method _fieldLiteralToString
- method _maxLiteralToString
- method _minLiteralToString
- method _sumLiteralToString
- method constructor
- method escape
- method escapeID
- method getConnection
- method getFieldDefaultValue
- method getIndexFieldsFromFieldIndex
- method setConnection
- method stackAssign
- method toConnectionString
-
class RealType
- method castToType
- method constructor
- method isValidValue
- method static getDisplayName
- method toString
-
class SerializedType
- method castToType
- method constructor
- method deserialize
- method getOptions
- method initialize
- method isDirty
- method isValidValue
- method onSetFieldValue
- method serialize
- method static getDisplayName
- method toString
-
class StringType
- method castToType
- method constructor
- method isValidValue
- method static getDisplayName
- method toString
-
class SumLiteral
- method static isAggregate
- method toString
-
class TextType
- method castToType
- method constructor
- method isValidValue
- method static getDisplayName
- method toString
-
class Type
- property _isMythixFieldType
- property clone
- method castToType
- method clone
- method constructor
- method deserialize
- method exposeToModel
- method getDisplayName
- method getField
- method getModel
- method initialize
- method isDirty
- method isForeignKey
- method isRelational
- method isRemote
- method isValidValue
- method isVirtual
- method onSetFieldValue
- method serialize
- method setField
- method setModel
- method static instantiateType
- method static isSameType
- method static isType
- method static isTypeClass
- method static wrapConstructor
- method toConnectionType
-
class UUIDV1Type
- property Default
- method castToType
- method getArgsForUUID
- method isValidValue
- method static getDisplayName
- method validateOptions
-
class UUIDV3Type
- property Default
- method castToType
- method getArgsForUUID
- method isValidValue
- method static getDisplayName
- method validateOptions
-
class UUIDV4Type
- property Default
- method castToType
- method getArgsForUUID
- method isValidValue
- method static getDisplayName
- method validateOptions
-
class UUIDV5Type
- property Default
- method castToType
- method getArgsForUUID
- method isValidValue
- method static getDisplayName
- method validateOptions
-
class XIDType
- property Default
- method castToType
- method isValidValue
- method static getDisplayName