class JackRussell(Dog): fields = { "age": NumberField() } def talk(self): return "Yap"
class Event(FamObject): use_rev = False additional_properties = False fields = { '_id': NumberField(), 'state': StringField(), } def get_calls_data(self): return f'{self.req} - {self.date}'
class Cat(GenericObject): fields = { "name": StringField(), "colour": StringField(immutable=True), "tail": BoolField(immutable=True, default=True), "legs": NumberField(required=True), "owner_id": ReferenceTo(NAMESPACE, "person", required=True), } @classmethod def all_with_n_legs(cls, db, legs): return db.view("animal_views/cat_legs", key=legs)
class User(FamObject): use_rev = False additional_properties = False fields = { '_id': NumberField(), 'name': StringField(), 'phone': StringField(), 'email': StringField(), 'birth': DateTimeField(), } def get_user_data(self): return f'{self.name} - {self.phone} - {self.email} - {self.birth}' def pre_save_new_cb(self, obj): print(self) print('something after save') return True