query<T extends Model> method
Query for kind
models with ancestorKey
.
Note that ancestorKey
is required, since a transaction is not allowed to
touch/look at an arbitrary number of rows.
Implementation
Query<T> query<T extends Model>(Key ancestorKey, {Partition? partition}) {
// TODO(#25): The `partition` element is redundant and should be removed.
if (partition == null) {
partition = ancestorKey.partition;
} else if (ancestorKey.partition != partition) {
throw ArgumentError(
'Ancestor queries must have the same partition in the ancestor key '
'as the partition where the query executes in.');
}
_checkSealed();
return Query<T>(db,
partition: partition,
ancestorKey: ancestorKey,
datastoreTransaction: _datastoreTransaction);
}