def create_concept_relationship(db: PartitionedDatabase, body: JsonDict) -> Tuple[JsonDict, int]: from_model = body.get("from", None) to_model = body.get("to", None) name = body["name"] display_name = body["display_name"] description = body["description"] with db.transaction() as tx: if from_model is None and to_model is None: relationship = to_legacy_relationship( db.create_model_relationship_stub_tx(tx, name=name, display_name=display_name, description=description)) else: relationship = to_legacy_relationship( db.create_model_relationship_tx( tx, from_model=from_model, name=name, display_name=display_name, to_model=to_model, one_to_many=True, description=description, )) return relationship, 201
def create_schema_linked_properties(db: PartitionedDatabase, id_: ModelId, body: JsonDict): with db.transaction() as tx: return ( [ to_schema_linked_property( db.create_model_relationship_tx( tx, from_model=id_, name=p["name"], to_model=p["to"], one_to_many=False, display_name=p["displayName"], index=p.get("position", None), )) for p in body ], 201, )