This commit is contained in:
wuaho 2021-07-28 17:31:37 +08:00
parent d32c2c22de
commit 579f1c820b
2 changed files with 6 additions and 0 deletions

View File

@ -86,6 +86,9 @@ async def delete(
"""删除报表""" """删除报表"""
# 删除Report 自己创建的 # 删除Report 自己创建的
del_report = await crud.report.delete(db, {'_id': data_in.id, 'user_id': current_user.id}) del_report = await crud.report.delete(db, {'_id': data_in.id, 'user_id': current_user.id})
# 从看板弹出
del_item = {'report_id': data_in.id}
await crud.dashboard.update_many(db, {}, {'$pull': {'reports': del_item}})
if del_report.deleted_count == 0: if del_report.deleted_count == 0:
return schemas.Msg(code=-1, msg='error', data='删除失败') return schemas.Msg(code=-1, msg='error', data='删除失败')

View File

@ -41,5 +41,8 @@ class CRUDBase:
async def update_one(self, db, filter, update, upsert=False): async def update_one(self, db, filter, update, upsert=False):
return await db[self.coll_name].update_one(filter, update, upsert) return await db[self.coll_name].update_one(filter, update, upsert)
async def update_many(self, db, filter, update, upsert=False):
return await db[self.coll_name].update_many(filter, update, upsert)
async def distinct(self, db, key, filter=None): async def distinct(self, db, key, filter=None):
return await db[self.coll_name].distinct(key, filter) return await db[self.coll_name].distinct(key, filter)