mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
allow creator relations
This commit is contained in:
parent
80c1da64c6
commit
9abeb13fbc
@ -2,7 +2,8 @@
|
||||
|
||||
const ACTIONS_TO_VERIFY = ['find'];
|
||||
|
||||
// FIXME: Support populating creator fields
|
||||
const { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = require('../../content-types').constants;
|
||||
|
||||
module.exports = auth => async ({ data, key, attribute }, { remove, set }) => {
|
||||
const isRelation = attribute.type === 'relation';
|
||||
|
||||
@ -42,12 +43,19 @@ module.exports = auth => async ({ data, key, attribute }, { remove, set }) => {
|
||||
};
|
||||
|
||||
const isMorphRelation = attribute.relation.toLowerCase().startsWith('morph');
|
||||
const isCreatorRelation = [CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE].includes(key);
|
||||
|
||||
// Polymorphic relations
|
||||
if (isMorphRelation) {
|
||||
await handleMorphRelation();
|
||||
}
|
||||
|
||||
// Creator relations
|
||||
else if (isCreatorRelation) {
|
||||
// do nothing
|
||||
// collections will transform/remove in api response based on populateCreatorFields
|
||||
}
|
||||
|
||||
// Regular relations
|
||||
else {
|
||||
await handleRegularRelation();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user