If populated, this group specifices a condition on a relationship.
If field
does not point to a related model, that's an error. It
could indicate that the GroupCondition
was instantiated with bad
data, or that the model metadata is incorrect.
Whether this GroupCondition is the result of an optimize call.
This is used to guard against infinitely fetch -> optimize -> fetch recursion.
The ModelMeta
of the model to query and/or filter against.
Expected to contain:
{
builder: ModelConstructor,
schema: SchemaModel,
pkField: string[]
}
If a field
is given, whether the relationship is a HAS_ONE
,
'HAS_MANY, or
BELONGS_TO`.
TODO: Remove this and replace with derivation using
ModelRelationship.from(this.model, this.field).relationship
;
Returns a copy of a GroupCondition, which also returns the copy of a given reference node to "extract".
A node of interest. Its copy will also be returned if the node exists.
Fetches matching records from a given storage adapter using legacy predicates (for now).
The storage adapter this predicate will query against.
For debugging/troubleshooting. A list of the groupId
's this
GroupdCondition.fetch is nested within.
Whether to match on the NOT
of this
.
An Promise
of any[]
from storage
matching the child conditions.
Determines whether a single item matches the conditions of this
.
When checking the target item
's properties, each property will be await
'd
to ensure lazy-loading is respected where applicable.
The item to match against.
Tells match()
that the field name has already been dereferenced.
(Used for iterating over children on HAS_MANY checks.)
A boolean (promise): true
if matched, false
otherwise.
Returns a version of the predicate tree with unnecessary logical groups
condensed and merged together. This is intended to create a dense tree
with leaf nodes (FieldCondition
's) aggregated under as few group conditions
as possible for the most efficient fetching possible -- it allows fetch()
.
E.g. a grouping like this:
and:
and:
id:
eq: "abc"
and:
name:
eq: "xyz"
Will become this:
and:
id:
eq: "abc"
name:
eq: "xyz"
This allows fetch()
to pass both the id
and name
conditions to the adapter
together, which can then decide what index to use based on both fields together.
Whether to preserve the current node and to explicitly not eliminate
it during optimization. Used internally to preserve the root node and children of
not
groups. not
groups will always have a single child, so there's nothing to
optimize below a not
(for now), and it makes the query logic simpler later.
Tranfsorm to a AppSync GraphQL compatible AST. (Does not support filtering in nested types.)
A JSON representation that's good for debugging.
Turn this predicate group into something a storage adapter understands how to use.
Creates a new GroupCondition
that contains only the local field conditions,
omitting related model conditions. That resulting GroupCondition
can be
used to produce predicates that are compatible with the storage adapters and
Cloud storage.
Whether the condition tree should be negated according to De Morgan's law.
A set of sub-conditions to operate against a model, optionally scoped to a specific field, combined with the given operator (one of
and
,or
, ornot
).groupId Used to distinguish between GroupCondition instances for debugging and troublehsooting.
model A metadata object that tells GroupCondition what to query and how.
field The field on the model that the sub-conditions apply to.
operator How to group child conditions together.
operands The child conditions.