Auto reloading a Sails.js app on code changes?

You have to use a watcher like forever, nodemon, or something else… Example Install forever by running: sudo npm install -g forever Run it: forever -w start app.js To avoid infinite restart because Sails writes into .tmp folder, you can create a .foreverignore file into your project directory and put this content inside: **/.tmp/** **/views/** … Read more

How to create global variables accessible in all views using Express / Node.JS?

After having a chance to study the Express 3 API Reference a bit more I discovered what I was looking for. Specifically the entries for app.locals and then a bit farther down res.locals held the answers I needed. I discovered for myself that the function app.locals takes an object and stores all of its properties … Read more

CRUD blueprint overriding in sails.js

Update In order to override blueprints in Sails 1.0 in the manner described below, you must first install the “custom blueprints” plugin for your project (npm install sails-hook-custom-blueprints). To override blueprints in Sails v0.10, you create an api/blueprints folder and add your blueprint files (e.g. find.js, create.js, etc.) within. You can take a look at … Read more

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