class Human(orm.Document): _db = "test" _collection = "humans" human_id = field.AutoIncrement(collection="human") name = field.Char(required=True, min=2, max=25) age = field.Integer(required=True, min=0, max=3000) height = field.Float(min=1, max=100000) weight = field.Float(min=1, max=30000) jobs = orm.List(type=Job) genitalia = field.Char() location = Location() car = field.ModelChoice(type=Car) color = field.Choice(choices=[{ 'value': 'red', 'display': 'Red' }, { 'value': 'blue', 'display': 'Blue' }, { 'value': 'green', 'display': 'Green' }]) state = field.CollectionChoice(db='test', collection='states', sort=[('fullname', 1)]) email = field.Email()
class User(mongodb.Document): _db = "rcr" _collection = "users" user_id = field.AutoIncrement(collection="users") username = field.Char(required=True, min=2, max=25) login_info = LoginInfo() user_stats = UserStats() def sysout(self): print self._json()
class Experiment(orm.Document): """ Base class for various experiments """ _db = "os_mongo" _collection = "experiments" experiment_id = field.AutoIncrement(collection="experiment") organization = field.Char(required=True) title = field.Char(required=True) description = field.Char(required=False) date = field.Date(required=True)
class Feature(orm.Document): """ Feature class """ _db = "os_mongo" _collection = "features" feature_id = field.AutoIncrement(collection="experiment") experiment_id = field.Integer(required=True) mass = field.Float(required=True) rt = field.Float(required=True) abundances = orm.List(type=Abundance) main_attribution = field.Char() annotations = orm.List(type=Annotation)
class Human(orm.Document): _db = "test" _collection = "humans" _indexes = [ orm.Index("name", key=[("name", orm.Index.DESCENDING)]), orm.Index("human_id", key=[("human_id", orm.Index.ASCENDING)]), orm.Index("geo_location", key=[("jobs.locations.geo", orm.Index.GEO2D)]) ] human_id = field.AutoIncrement(collection="human") name = field.Char(required=True, min=2, max=25) age = field.Integer(min=0, max=3000) height = field.Float(min=1, max=100000) weight = field.Float(min=1) jobs = orm.List(type=Job, length=3) genitalia = field.Char()
class User(mongodb.Document): _db = "rcr" _collection = "users" user_id = field.AutoIncrement(collection="users") username = field.Char(required=True, min=2, max=25) login_info = LoginInfo() user_stats = UserStats() # not the reserved init function def init(self, userDict=None): self.username = userDict.get('username') self.login_info = LoginInfo() self.login_info.init(userDict) self.user_stats = UserStats() def sysout(self): print self._json()