Browse Source

feat: OldData - dataDelete

pull/5444/head
Wing-Kam Wong 2 years ago committed by Pranav C
parent
commit
522fe00bb6
  1. 19
      packages/nocodb-nest/src/modules/datas/old-datas/old-datas.controller.ts
  2. 12
      packages/nocodb-nest/src/modules/datas/old-datas/old-datas.service.ts

19
packages/nocodb-nest/src/modules/datas/old-datas/old-datas.controller.ts

@ -69,4 +69,23 @@ export class OldDatasController {
}), }),
); );
} }
@Delete('/nc/:projectId/api/v1/:tableName/:rowId')
@Acl('dataDelete')
async dataDelete(
@Request() req,
@Response() res,
@Param('projectId') projectId: string,
@Param('tableName') tableName: string,
@Param('rowId') rowId: string,
) {
res.json(
await this.oldDatasService.dataDelete({
projectId: projectId,
tableName: tableName,
rowId,
cookie: req,
}),
);
}
} }

12
packages/nocodb-nest/src/modules/datas/old-datas/old-datas.service.ts

@ -113,6 +113,18 @@ export class OldDatasService {
return await baseModel.updateByPk(param.rowId, param.body, null, param); return await baseModel.updateByPk(param.rowId, param.body, null, param);
} }
async dataDelete(param: OldPathParams & { rowId: string; cookie: any }) {
const { model, view } = await this.getViewAndModelFromRequest(param);
const base = await Base.get(model.base_id);
const baseModel = await Model.getBaseModelSQL({
id: model.id,
viewId: view.id,
dbDriver: await NcConnectionMgrv2.get(base),
});
return await baseModel.delByPk(param.rowId, null, param.cookie);
}
async getViewAndModelFromRequest(req) { async getViewAndModelFromRequest(req) {
const project = await Project.getWithInfo(req.params.projectId); const project = await Project.getWithInfo(req.params.projectId);
const model = await Model.getByAliasOrId({ const model = await Model.getByAliasOrId({

Loading…
Cancel
Save