strapi/lib/configuration/hooks/waterline/helpers/isOneToManyAssociation.js

25 lines
514 B
JavaScript
Raw Normal View History

2015-10-01 00:30:16 +02:00
'use strict';
/**
* Module dependencies
*/
// Public node modules.
const _ = require('lodash');
/**
* Helper which returns a boolean. True if the type
* of the relation is `oneToMany`.
*
* @param {Object} currentModel
* @param {Object} association
*
* @return {boolean}
*/
module.exports = function isOneToManyAssociation(currentModel, association) {
return _.findWhere(strapi.models[association.collection] && strapi.models[association.collection].associations, {
model: currentModel
});
};