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

How do I convert an image to a base64-encoded data URL in sails.js or generally in the servers side JavaScript?

As I understand you want to convert a file into base64 encoded string. Whether the file is image or not, that does not matter. var fs = require(‘fs’); // function to encode file data to base64 encoded string function base64_encode(file) { // read binary data var bitmap = fs.readFileSync(file); // convert binary data to base64 … Read more

Sails.js vs Meteor – What are the advantages of both? [closed]

I can’t speak for Meteor, but I can help provide a little background on Sails because I created it. tldr; Sails is not a panacea for all of the web’s problems– but I believe Node.js is. The goal of Sails is to provide a practical framework for developing complete, scalable, startup and enterprise-friendly applications built … 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

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)