Returns the underlying mongoalchemy.fields.Field
Represents the matched array index on a query with objects inside of a list. In the MongoDB docs, this is the $ operator
Returns the full dotted name of this field
A query to check if a field starts with a given prefix string
Example: session.query(Spell).filter(Spells.name.startswith("abra", ignore_case=True))
Note
This is a shortcut to .regex(‘^’ + re.escape(prefix)) MongoDB optimises such prefix expressions to use indexes appropriately. As the prefix contains no further regex, this will be optimized by matching only against the prefix.
A query to check if a field ends with a given suffix string
Example: session.query(Spell).filter(Spells.name.endswith("cadabra", ignore_case=True))
A query to check if a field matches a given regular expression :param ignore_case: Whether or not to ignore the case (setting this to True is the same as setting the ‘i’ option) :param options: A string of option characters, as per the MongoDB $regex operator (e.g. “imxs”)
Example: session.query(Spell).filter(Spells.name.regex(r'^abra[a-z]*cadabra$', ignore_case=True))
Return documents near the given point
Return documents near the given point using sphere distances
Adapted from the Mongo docs:
session.query(Places).filter(Places.loc.within_box(cornerA, cornerB)
Adapted from the Mongo docs:
session.query(Places).filter(Places.loc.within_radius(1, 2, 50)
Adapted from the Mongo docs:
session.query(Places).filter(Places.loc.within_radius_sphere(1, 2, 50)
Adapted from the Mongo docs:
polygonA = [ [ 10, 20 ], [ 10, 40 ], [ 30, 40 ], [ 30, 20 ] ]
polygonB = { a : { x : 10, y : 20 }, b : { x : 15, y : 25 }, c : { x : 20, y : 20 } }
session.query(Places).filter(Places.loc.within_polygon(polygonA)
session.query(Places).filter(Places.loc.within_polygon(polygonB)
A query to check if this query field is one of the values in values. Produces a MongoDB $in expression.
A query to check if this query field is not one of the values in values. Produces a MongoDB $nin expression.
Create a MongoDB query to check if a field exists on a Document.
Creates a query expression where this field == value
Note
The prefered usage is via an operator: User.name == value
Creates a query expression where this field < value
Note
The prefered usage is via an operator: User.name < value
Creates a query expression where this field <= value
Note
The prefered usage is via an operator: User.name <= value
Creates a query expression where this field != value
Note
The prefered usage is via an operator: User.name != value
Creates a query expression where this field > value
Note
The prefered usage is via an operator: User.name > value
Creates a query expression where this field >= value
Note
The prefered usage is via an operator: User.name >= value
This method does two things depending on the context:
Creates a query expression to do an $elemMatch on the selected field. If the type of this field is a DocumentField the value can be either a QueryExpression using that Document’s fields OR you can use a dict for raw mongo.
See the mongo documentation for thorough treatment of elemMatch: http://docs.mongodb.org/manual/reference/operator/elemMatch/
Sets the field to use elemMatch, so only the matching elements of a list are used. See the mongo docs for more details: http://docs.mongodb.org/manual/reference/projection/elemMatch/
Use in a query.fields() expression to say this field should be excluded. The default of fields() is to include only fields which are specified. This allows retrieving of “every field except ‘foo’”.
A QueryExpression wraps a dictionary representing a query to perform on a mongo collection. The
Note
There is no and_ expression because multiple expressions can be specified to a single call of Query.filter()
Negates this instance’s query expression using MongoDB’s $not operator
Example: (User.name == 'Jeff').not_()
Note
Another usage is via an operator, but parens are needed to get past precedence issues: ~ (User.name == 'Jeff')
Adds the given expression to this instance’s MongoDB $or expression, starting a new one if one does not exst
Example: (User.name == 'Jeff').or_(User.name == 'Jack')
Note
The prefered usageis via an operator: User.name == 'Jeff' | User.name == 'Jack'