The find() method on extents now supports more complex criteria!
Taking a que from other database packages, such as Divmod Axiom and SqlAlchemy, Schevo now supports the use of Python operators to allow for criteria other than simple equality when using find().
You can check whether fields are ==, !=, <, <=, >, and >= a value. You can combine expressions using & and | for "and"/"or" operations.
Please note that operator precedence is not implemented. Place all inner expressions within parentheses to make sure they are evaluated in the desired order.
Here are some example expressions:
Note that you can still use the old-style keyword arguments for simple equality. For example, the following are equivalent:
results = db.Sightings.find(date='2009-01-01', people=5, aliens=1)
f = db.Sightings.f
results = db.Sightings.find((f.date == '2009-01-01') & (f.people == 5) & (f.aliens == 1))
The former is good if you are simply doing equality checking. The latter is more verbose, but is necessary for more complex criteria.
Also of note is that the <, <=, >, and >= operators currently use brute-force to find matches. This is an implementation detail; in the future we'll optimize those to use indices when available.
--
Matthew R. Scott