python mongo engine code example
Example 1: python MongoEngine doc
young_users = Users.objects(age__lte=18)
equal_18 = Users.objects(age__not__ne=18)
"""
# Only find users whose age is 18 or less
young_users = Users.objects(age__lte=18)
Available operators are as follows:
ne – not equal to
lt – less than
lte – less than or equal to
gt – greater than
gte – greater than or equal to
not – negate a standard check, may be used before other operators (e.g. Q(age__not__mod=(5, 0)))
in – value is in list (a list of values should be provided)
nin – value is not in list (a list of values should be provided)
mod – value % x == y, where x and y are two provided values
all – every item in list of values provided is in array
size – the size of the array is
exists – value for field exists
"""
Example 2: mongoengine
from mongoengine import *
connect('tumblelog')