Queries
A query is built from a class’s references, which mirror its fields:
from drivine import any_of, not_, refs
q = refs(PersonCareer)leads = await gom.load_all( PersonCareer, where=q.person.bio.contains("Lead"), order_by=q.person.name.asc(), limit=20,)
await gom.load_all(PersonCareer, where=[ # a list: all must hold q.employment_history.target.name.eq("Acme"), # across a relationship any_of(q.person.name.eq("Ada"), q.person.name.eq("Grace")), not_(q.person.bio.is_null()),])
# one relationship that meets both, rather than each met by anyq.employment_history.any(lambda it: [it.role.eq("Engineer"), it.target.name.eq("Acme")])q.employment_history.none(lambda it: it.role.eq("Lead"))- Operators:
eq,neq,gt,gte,lt,lte,in_,not_in,contains,starts_with,ends_with,matches,contains_ignore_case,eq_ignore_case,has_item,is_null,is_not_null. On a node:instance_of(Type),has_any_label(...), andproperty(name)orpredicate(name, operator, value)for a property named at run time by its stored name. - Fields go by their Python names,
q.start_date, and Drivine writes the stored names. A field the class doesn’t have fails as the query is written, naming it and the class.q.x == 1raises: writeq.x.eq(1). - Order and pages:
order_bytakes terms,asc()ordesc(), thennulls_first()ornulls_last();limitandskipapply in the database. An order on a list relationship’s property sorts that list in each object. - Keyset pages:
seek=[q.released.after(last.released), q.uuid.after(last.uuid)], one value for each term oforder_by, ending with a unique key. - An order by an expression:
plus,minus,times,div,negate,exp,floor,coalesce,case_ofwithabove,below,at_least,at_most,equal_to,has_valueand the rest, all computed in the database. count,delete,delete_allandpatchtake conditions too.eq_ignore_caseandcontains_ignore_caselowercase the property, which no index reads. On aCaseInsensitivefield whose index ignores case, they compare with a lowercased copy instead, which the index serves: see below.

