Sails.js populate nested associations

Or you can use the built-in Blue Bird Promise feature to make it. (Working on [email protected]) 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

How to populate a table with a range of dates?

Try this: DROP PROCEDURE IF EXISTS filldates; DELIMITER | CREATE PROCEDURE filldates(dateStart DATE, dateEnd DATE) BEGIN WHILE dateStart <= dateEnd DO INSERT INTO tablename (_date) VALUES (dateStart); SET dateStart = date_add(dateStart, INTERVAL 1 DAY); END WHILE; END; | DELIMITER ; CALL filldates(‘2011-01-01′,’2011-12-31′); Here’s the SQL Fiddle to play with it: http://sqlfiddle.com/#!2/65d13/1 EDIT (to check if … Read more