Hands On Sails.js, build Node.js webapps in minutes.

Installing Sails

npm install sails -g
npm install sails-mysql --save

Let’s get started

sails new myproject
sails lift

Create your backend API

sails generate api users


Database adapter

attributes: {
firstname: {type: 'string'},
lastname: {type: 'string'}

Page design

Let’s interact with the DB from the frontend

<a href=”/users/displayAll”>Display users</a>
module.exports = {
displayAll:function(request, response){
Users.find({}).exec(function(err, users){
if(err){res.send(500, 'Query failed');}
response.view('displayAll', {users: users});
<th>First Name</th>
<th>Last Name</th>
<% users.forEach(function(user){ %>
<td> <%= user.id %> </td>
<td> <%= user.firstname %> </td>
<td> <%= user.lastname %> </td>
<% }) %>

Edit API methods or create custom ones

'GET /helloworld': {blueprint: 'helloworld'}




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store