strapi/packages/core/utils/lib/relations.js
2021-04-29 12:03:54 +02:00

18 lines
442 B
JavaScript

'use strict';
const { prop } = require('lodash/fp');
const MANY_RELATIONS = ['oneToMany', 'manyToMany', 'manyWay'];
const RF_RELATIONS = ['oneToMany', 'manyToMany', 'manyWay', 'manyToOne', 'oneWay', 'oneToOne'];
const getRelationalFields = modelDef => {
return modelDef.associations.filter(a => RF_RELATIONS.includes(a.nature)).map(prop('alias'));
};
module.exports = {
getRelationalFields,
constants: {
MANY_RELATIONS,
},
};