mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Return correct fields on /fields/:collection
This commit is contained in:
@@ -35,7 +35,7 @@ router.get(
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new FieldsService({ accountability: req.accountability });
|
||||
|
||||
const fields = await service.readAll(req.collection);
|
||||
const fields = await service.readAll(req.params.collection);
|
||||
return res.json({ data: fields || null });
|
||||
})
|
||||
);
|
||||
@@ -50,7 +50,7 @@ router.get(
|
||||
const exists = await schemaInspector.hasColumn(req.collection, req.params.field);
|
||||
if (exists === false) throw new FieldNotFoundException(req.collection, req.params.field);
|
||||
|
||||
const field = await service.readOne(req.collection, req.params.field);
|
||||
const field = await service.readOne(req.params.collection, req.params.field);
|
||||
return res.json({ data: field || null });
|
||||
})
|
||||
);
|
||||
|
||||
@@ -100,7 +100,8 @@ router.post(
|
||||
}
|
||||
|
||||
const record = await service.readByKey(keys as any, req.sanitizedQuery);
|
||||
return res.json({ data: record || null });
|
||||
|
||||
return res.json({ data: res.locals.savedFiles.length === 1 ? record[0] : record || null });
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -81,10 +81,16 @@ export default class FieldsService {
|
||||
return data as Field;
|
||||
});
|
||||
|
||||
let aliasFields = await this.knex
|
||||
const aliasQuery = this.knex
|
||||
.select<FieldMeta[]>('*')
|
||||
.from('directus_fields')
|
||||
.whereIn('special', ['alias', 'o2m']);
|
||||
.whereIn('special', ['alias', 'o2m', 'm2m']);
|
||||
|
||||
if (collection) {
|
||||
aliasQuery.andWhere('collection', collection);
|
||||
}
|
||||
|
||||
let aliasFields = await aliasQuery;
|
||||
|
||||
aliasFields = (await this.payloadService.processValues('read', aliasFields)) as FieldMeta[];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user