Пример #1
0
def create_relationship(db: PartitionedDatabase, model_id_or_name: str,
                        body: JsonDict) -> Tuple[JsonDict, int]:
    # connexion converts "type" to "type_":
    return (
        db.create_model_relationship(
            from_model=model_id_or_name,
            name=body["type_"],
            to_model=body["to"],
            one_to_many=body["one_to_many"],
            display_name=body.get("display_name", body["type_"]),
        ).to_dict(),
        201,
    )
Пример #2
0
def create_schema_linked_property(db: PartitionedDatabase, id_: ModelId,
                                  body: JsonDict):
    return (
        to_schema_linked_property(
            db.create_model_relationship(
                from_model=id_,
                name=body["name"],
                to_model=body["to"],
                one_to_many=False,
                display_name=body["display_name"],
                index=body.get("position", None),
            )),
        201,
    )