{ 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!

Sails – Working with Policies

1. Creating SailsJs Project Follow the below tutorial for setting up SailsJs Setting up sails project 2. Creating Controller Generate a controller using the below command sails generate controller User copy the below code and paste in api/controllers/UserController.js module.exports = { policiesValidation: function (req, res) { res.send({ success: true, message: . . . 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

One to Many Association

In this tutorial we will be covering One-to-One associations in SailsJs Models 1. Creating SailsJs Project Follow the below tutorial for setting up SailsJs Setting up sails project 2. MySQL Database Setup We will be using MySQL DB for this tutorial. You can follow the below tutorial about setting up . . . Read more

Sails – One to Many Association

In this tutorial we will be covering One-to-One associations in SailsJs Models 1. Creating SailsJs Project Follow the below tutorial for setting up SailsJs Setting up sails project 2. MySQL Database Setup We will be using MySQL DB for this tutorial. You can follow the below tutorial about setting up . . . Read more

One to One Association

In this tutorial we will be covering One-to-One associations in SailsJs Models 1. Creating SailsJs Project Follow the below tutorial for setting up SailsJs Setting up sails project 2. MySQL Database Setup We will be using MySQL DB for this tutorial. You can follow the below tutorial about setting up . . . 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

Callback to Promises

As we all know Sails works on Non-Blocking I/O and due to which callbacks are used. Callback is invoked on completion of the function block and returns the control back to the calling function. Callbacks are good for developers who are getting started with SailsJs, as it is easy to . . . Read more

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