query<T extends Model> method
Build a query for kind
models.
Implementation
Query<T> query<T extends Model>({Partition? partition, Key? ancestorKey}) {
// TODO(#26): There is only one case where `partition` is not redundant
// Namely if `ancestorKey == null` and `partition != null`. We could
// say we get rid of `partition` and enforce `ancestorKey` to
// be `Partition.emptyKey`?
if (partition == null) {
if (ancestorKey != null) {
partition = ancestorKey.partition;
} else {
partition = defaultPartition;
}
} else if (ancestorKey != null && partition != ancestorKey.partition) {
throw ArgumentError(
'Ancestor queries must have the same partition in the ancestor key '
'as the partition where the query executes in.');
}
return Query<T>(this, partition: partition, ancestorKey: ancestorKey);
}