{ sailsit }

Sails Js Tutorials for Beginners and Forum

Have a Question?

If you have any question you can ask below or enter what you are looking for!

All posts in Getting Started

Upload Files – AWS S3

1. Creating SailsJs Project Follow the below tutorial for setting up SailsJs Setting up sails project 2. Creating Controller Use the below command to generate a controller sails generate controller Upload paste the below code in api/controllers/UploadController.js /** * UploadController * * @description :: Server-side logic for managing Uploads * . . . Read more


As almost all of the developers find it difficult to stop sails and run it again for any changes done in the code. Today we will use a npm package which provides auto reloading of sails whenever there is a change in the code. Let’s get started 1. Creating SailsJs . . . Read more

Schedule Jobs

1. Creating SailsJs Project Follow the below tutorial for setting up SailsJs Setting up sails project 2. Installing Packages For creating jobs we need to install sails-hook-jobs package, this package is available in npm. To install the package use the below command npm install sails-hook-jobs –save   3. Database Setup . . . Read more

Disable Hooks or Generators or Modules

Sails provides a feature to disable specific packages or plugins which are used in Sails. To disable any of the hooks or generators or modules in sailsjs, you can set the feature as false in .sailsrc You can check below, for sample code for disabling any hooks { “generators”:{}, “modules”:{}, . . . Read more

SailsJS – Log Queries

SailsJs provides a feature to Log queries in console. To log queries, use the below command to start your sails application LOG_QUERIES=true sails lift   Setting LOG_QUERIES env while starting sails, will start logging queries with other sails logs. Note: It will not log MongoDB Queries

File Logging with LogRotate

Sails comes with winston package preinstalled, which we will be using with some other packages in this tutorial to enable file logging in sails. Let’s get started 1. Creating Project Create a new SailsJs project. Follow this post on Setting up sails project 2. Logging directory Create a directory log . . . Read more

MongoDB and MySQL Configuration

1. Create new project You can follow this tutorial for setting up sails project Setting up Sails project 2. Installing Packages To use MySQL/MongoDB, first you need to install adapter for it Install sails-mongo adapter using npm. npm install sails-mongo –save   Install sails-mysql adapter using npm npm install sails-mysql . . . Read more

Setting Up Sails Project

1. Creating Project Create a new sails project using below command sails new sails-first-project   2. Configuring Database Configure your DB connections config/connections.js Sails supports, MongoDB, MySQL, PostgreSQL 3. Configuring Models Configure DB connection name in config/models.js Note: Use exact DB connection name as defined in config/connections.js Change migrate method . . . Read more

Model Functions – Waterline | REST API

SailsJs comes with WATERLINE (ORM) pre-installed, WATERLINE provides some Model functions which are used for querying database We will check usage of these Model functions in this tutorial with example codes 1. Create a Model names Movies using below command sails generate model Movies copy the below code in api/models/Movies.js . . . Read more

Simple CRUD Operations – REST API

1. Setting up SailsJS Environment First you need to setup Sails project. You can follow the guide on Sails official website Getting Started with SailsJS 2. Creating Project Run this command in any directory sails create sails-crud-simple This command will create new project with all the required dependencies 3. Setting . . . Read more