lib/index.js
function(schema, from) {
    return function(next) {
        var self = this;
        var funcs = [];
    
        for (var key in from) {
            var items = from[key];
            var model = mongoose.model(schema.path(key).options.ref);
        
            funcs.push(function(callback) {
                model.findOne({ _id: self[key] }, function(err, instance) {
                    if (err) return callback(err);
                
                    items.forEach(function(item) {
                        self[item.key] = instance[item.field];
                    });
                
                    callback();
                });
            });
        }
    
        async.parallel(funcs, function(err) {
            if (err) return next(err);
            next();
        });
    };
}
function(schema, from) {
    return function(next) {
        var self = this;
        var funcs = [];
    
        for (var key in from) {
            var items = from[key];
            var model = mongoose.model(schema.path(key).options.ref);
        
            funcs.push(function(callback) {
                model.findOne({ _id: self[key] }, function(err, instance) {
                    if (err) return callback(err);
                
                    items.forEach(function(item) {
                        self[item.key] = instance[item.field];
                    });
                
                    callback();
                });
            });
        }
    
        async.parallel(funcs, function(err) {
            if (err) return next(err);
            next();
        });
    };
}
function ( schema , from ) { return function ( next ) { var self = this ; var funcs = [ ] ; for ( var key in from ) { var items = from [ key ] ; var model = mongoose . model ( schema . path ( key ) . options . ref ) ; funcs . push ( function ( callback ) { model . findOne ( { _id : self [ key ] } , function ( err , instance ) { if ( err ) return callback ( err ) ; items . forEach ( function ( item ) { self [ item . key ] = instance [ item . field ] ; } ) ; callback ( ) ; } ) ; } ) ; } async . parallel ( funcs , function ( err ) { if ( err ) return next ( err ) ; next ( ) ; } ) ; } ; }
Denormalize values from foreign refs into local model
Denormalize values from foreign refs into local model