mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
Remove batch delete for fields/collections
It's too destructive
This commit is contained in:
@@ -99,24 +99,6 @@ router.patch(
|
||||
respond
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/',
|
||||
asyncHandler(async (req, res, next) => {
|
||||
if (!req.body || Array.isArray(req.body) === false) {
|
||||
throw new InvalidPayloadException(`Body has to be an array of primary keys`);
|
||||
}
|
||||
|
||||
const collectionsService = new CollectionsService({
|
||||
accountability: req.accountability,
|
||||
schema: req.schema,
|
||||
});
|
||||
await collectionsService.delete(req.body as string[]);
|
||||
|
||||
return next();
|
||||
}),
|
||||
respond
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/:collection',
|
||||
asyncHandler(async (req, res, next) => {
|
||||
|
||||
@@ -112,43 +112,6 @@ router.post(
|
||||
respond
|
||||
);
|
||||
|
||||
router.patch(
|
||||
'/:collection',
|
||||
validateCollection,
|
||||
asyncHandler(async (req, res, next) => {
|
||||
const service = new FieldsService({
|
||||
accountability: req.accountability,
|
||||
schema: req.schema,
|
||||
});
|
||||
|
||||
if (Array.isArray(req.body) === false) {
|
||||
throw new InvalidPayloadException('Submitted body has to be an array.');
|
||||
}
|
||||
|
||||
for (const field of req.body) {
|
||||
await service.updateField(req.params.collection, field);
|
||||
}
|
||||
|
||||
try {
|
||||
let results: any = [];
|
||||
for (const field of req.body) {
|
||||
const updatedField = await service.readOne(req.params.collection, field.field);
|
||||
results.push(updatedField);
|
||||
res.locals.payload = { data: results || null };
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof ForbiddenException) {
|
||||
return next();
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
return next();
|
||||
}),
|
||||
respond
|
||||
);
|
||||
|
||||
router.patch(
|
||||
'/:collection/:field',
|
||||
validateCollection,
|
||||
|
||||
Reference in New Issue
Block a user