예제 #1
0
def read():
    key = request.args.keys()[0]
    value = request.arg[key]
    if key is not None and value is not None:
        reponse = PersonColl.find_one({key: value})
        model = PersonModel.parse_json(reponse)
        jsonify(model.to_json())
    else:
        reponse = PersonColl.find()
        list = []
        for result in reponse:
            model = PersonModel.parse_json(result, hasid=True)
            list.append(model.to_json(include_id=True))
        return jsonify(list)
예제 #2
0
def insert():
    result = request.get_json()
    model = PersonModel.parse_json(result)
    PersonColl.insert_one(model.to_json())
    return Response(status=200)