async def get_patient_collects(): for patient in db.patients.find(): collects = [] for collect in db.collects.find({'patient': patient['_id']}): collects.append(Collect(**collect)) db.patient.update({'_id': patient['_id']}, {'$set': { 'collects': collects }})
async def list_collects(user: User = Depends(get_current_active_user)): collects = [] for collect in db.collects.find(): collects.append(Collect(**collect)) return collects
def create_collect(): request_data = request.get_json() collect = Collect(**request_data).save() return jsonify(collect)