# all files / keystone/lib/schemaPlugins/methods/ populateRelated.js

22.22% Statements 2/9
0% Branches 0/2
0% Functions 0/3
22.22% Lines 2/9

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    191×

    1×

     var _ = require('lodash');

    module.exports = function populateRelated (rel, callback) {

    	var item = this;

    	if (typeof callback !== 'function') {
    		throw new Error('List.populateRelated(rel, callback) requires a callback function.');
    	}

    	this.getRelated(rel, function (err, results) {
    		_.forEach(results, function (data, key) {
    			item[key] = data;
    		});
    		callback(err, results);
    	}, true);

    };