class User(Model, metaclass=ModelMeta): global_namespace = True id = IdField(required=True) username = StringField(required=True, unique=True) email = StringField(required=False, unique=True) password = PasswordField(required=True) organization = RelationField(required=True, remote_class_name='Organization') created_at = DatetimeField(default=datetime.utcnow) role = StringField(required=True) active = BoolField(required=True) metadata = JSONField(required=False) auth = StringField() @property def namespace(self): """ Get namespace from organization. Returns: str: Namespace (from organization) """ return self.organization.namespace
class TestModel(Model, metaclass=ModelMeta): if global_ns: global_namespace = global_ns id = IdField(required=required, encrypted=encrypted, unique=unique) string = StringField(required=required, encrypted=encrypted, unique=unique) json = JSONField(required=required, encrypted=encrypted, unique=unique) password = PasswordField(required=required, encrypted=encrypted, unique=unique) relation = RelationField(required=required, encrypted=encrypted, unique=unique) datetime = DatetimeField(required=required, encrypted=encrypted, unique=unique) boolean = BoolField(required=required, encrypted=encrypted, unique=unique) _required = required _global_ns = global_ns _encrypted = encrypted if _global_ns: _namespace = None else: _namespace = namespace