1,583
edits
Changes
no edit summary
Each of these QuerySets allows you to chain together a series of QuerySet method calls. QuerySet supports the following methods:
* .proxyselect(name[fields...]) - returns generator* .order(fieldname, args...) - applies a namedorder-proxy (by fields given as strings; use "living-name", "private", or "referenced")for descending
* .filter(obj, args...) - applies a FilterObject or Python callable
* .map(f) - applies a function to all selected objects
* .proxy(name, args...) - applies a named-proxy ("living", "private", or "referenced")
* .limit() - set start or limit or selection
* .count() - returns the number of matches
* .tag(tag_name) - puts a tag on all selected items, if not tagged with tag_name already
These methods can be lined up to create a series of operations:
db.Person.filter(lambda person: person.private=True).select("gramps_id")
== Database.QuerySet.select() ==
db.Person.select()
== Database.QuerySet.filterorder() ==
db.Person.order("gramps_id").select()
Barry, I0011
== Database.QuerySet.filter() == == Database.QuerySet.map() == == Database.QuerySet.proxy() == == Database.QuerySet.limit() == == Database.QuerySet.count() == == Database.QuerySet.tag() == == Joins ===
The database.select method can also do joins across primary objects in each of the WHERE, ORDER, or select fields. For example consider this request:
]
Note that these joins are done per record and are therefore not yet optimized---each requires another database access. In the future, these could be optimized via a SQL JOIN.
== Implementation ==