Sails.js populate nested associations

Or you can use the built-in Blue Bird Promise feature to make it. (Working on Sails@v0.10.5) See the codes below: var _ = require(‘lodash’); … Post .findOne(req.param(‘id’)) .populate(‘user’) .populate(‘comments’) .then(function(post) { var commentUsers = User.find({ id: _.pluck(post.comments, ‘user’) //_.pluck: Retrieves the value of a ‘user’ property from all elements in the post.comments collection. }) .then(function(commentUsers) … Read more

tech