mirror of
https://github.com/strapi/strapi.git
synced 2025-07-18 22:45:47 +00:00
18 lines
442 B
JavaScript
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,
|
|
},
|
|
};
|