strapi/lib/configuration/hooks/waterline/helpers/isOneToOneAssociation.js
2015-10-01 00:30:16 +02:00

25 lines
502 B
JavaScript

'use strict';
/**
* Module dependencies
*/
// Public node modules.
const _ = require('lodash');
/**
* Helper which returns a boolean. True if the type
* of the relation is `oneToOne`.
*
* @param {Object} currentModel
* @param {Object} association
*
* @return {boolean}
*/
module.exports = function isOneToOneAssociation(currentModel, association) {
return _.findWhere(strapi.models[association.model] && strapi.models[association.model].associations, {
model: currentModel
});
};