class SchematicsFieldsModel(BaseModel): # base fields type_string = types.StringType() type_int = types.IntType() type_uuid = types.UUIDType() type_IPv4 = types.IPv4Type() type_url = types.URLType() type_email = types.EmailType() type_number = types.NumberType(int, "integer") type_int = types.IntType() type_long = types.LongType() type_float = types.FloatType() type_decimal = types.DecimalType() type_md5 = types.MD5Type() type_sha1 = types.SHA1Type() type_boolean = types.BooleanType() type_date = types.DateType() type_datetime = types.DateTimeType() type_geopoint = types.GeoPointType() # type_multilingualstring = types.MultilingualStringType(default_locale='localized_value') # compound fields type_list = compound.ListType(types.StringType) type_dict = compound.DictType( types.IntType) # dict values can be only integers type_list_of_dict = compound.ListType(compound.DictType, compound_field=types.StringType) type_dict_of_list = compound.DictType(compound.ListType, compound_field=types.IntType) type_model = compound.ModelType(NestedModel) type_list_model = compound.ListType(compound.ModelType(NestedModel)) # reference fields type_ref_simplemodel = ModelReferenceType(SimpleModel) type_ref_usermodel = ModelReferenceType(User) class Options: # namespace = 'st' collection = 'st' serialize_when_none = False
class Topic(BaseModel): title = types.StringType(default='best') ancestor = ModelReferenceType('self') class Options: indexes = ({'fields': 'title', 'unique': True}, )
class RecordSeries(BaseModel): title = types.StringType() records = compound.ListType(ModelReferenceType(Record)) simplies = compound.ListType(ModelReferenceType(SimpleModel)) main_event = ModelReferenceType(Event)
class Record(BaseModel): title = types.StringType() event = ModelReferenceType(Event) simple = ModelReferenceType(SimpleModel)
class Event(BaseModel): title = types.StringType() user = ModelReferenceType(User) class Options: indexes = ({'fields': ('title', 'user.name')}, )
class ParentBase(BaseModel): friends = compound.ListType( ModelReferenceType(ChildB, reverse_delete_rule=PULL))
class ParentSublcassed(ParentBase): guru = ModelReferenceType(ChildC, reverse_delete_rule=NULLIFY)
class ParentMixin(Model): """ Need to subclass schematics.Model, so declared fields will be collected """ friends = compound.ListType( ModelReferenceType(ChildB, reverse_delete_rule=PULL))
class ParentK(BaseModel, ParentMixin): guru = ModelReferenceType(ChildC, reverse_delete_rule=NULLIFY)
class ParentG(BaseModel): childs = compound.ListType( ModelReferenceType(ChildA, reverse_delete_rule=CASCADE))
class ParentI(BaseModel): childs = compound.ListType( ModelReferenceType(ChildA, reverse_delete_rule=PULL))
class ParentE(BaseModel): childs = compound.ListType( ModelReferenceType(ChildA, reverse_delete_rule=DO_NOTHING))
class ParentD(BaseModel): child = ModelReferenceType(ChildA, reverse_delete_rule=DENY)
class ParentC(BaseModel): child = ModelReferenceType(ChildA, reverse_delete_rule=CASCADE)
class ParentB(BaseModel): child = ModelReferenceType(ChildA, reverse_delete_rule=NULLIFY)
class ParentA(BaseModel): child = ModelReferenceType(ChildA, reverse_delete_rule=DO_NOTHING)