datoit-utils
Version:
Shared utilities for the Datoit packages
18 lines (13 loc) • 442 B
JavaScript
;
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,
},
};