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

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

Raw Native Queries

1. Creating SailsJs Project Follow the below tutorial for setting up SailsJs Setting up sails project 2. Database Setup You can follow the below tutorial about setting up MySQL & MongoDb Setting up MySQL & MongoDB in SailsJs 3. Creating Models Use the below command to generate People model sails . . . Read more

SES Email Trigger

1. Creating SailsJs Project Follow the below tutorial for setting up SailsJs Setting up sails project 2. Installing Packages To install the package use the below command npm install node-ses –save npm install ejs –save   3. Creating Email Template We will also need an email template for sending the . . . Read more

Waterline ORM – To use or not to use

We are a fan of sail.js but one thing which remained a mystery to us was whether to use the sails.js waterline ORM and not. During our development phase, we had encountered various problems such as processing latency, poor performance etc as our database grew. We analyzed the performance of . . . Read more

SMTP Email Trigger

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-email package, this package is developed by Balderdash To install the package use the below command npm install sails-hook-email –save   3. Configuring SMTP . . . Read more

Unit Testing with Mocha.js

Mocha.js is Javascript test framework, which can be used for writing unit test, and test your code. In this tutorial we will be writing unit tests for testing RestAPI built in SailsJs 1. Setting up project For this tutorial we will be using our sails-simple-crud project, which we can created . . . Read more

Custom Promise

In sails we can write a custom promise, which can be used to convert any piece of code into promise Below is an example of writing custom promise function: getData() { return new Promise(function(resolve, reject){ Model.find().exec(function(err, result){ if(err) { reject(err); } resolve(result); }); }); }   In the above method, . . . Read more

Autoreload

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

Sails – Mongo ReplicaSet Configuration

In SailsJs, to configure replica set for MongoDB You can use MongoURI directly with all the details in your connnections.js file Below is the MongoURI format "mongodb://{replicaSet1}:{port},{replicaSet2}:{port},{replicaSetN}:{port}/{dbName}?replSet={replicaSetName}&readPreference=nearest&slaveOk=true"   The above URI then can be used in Sails config/connections.js as below mongoDB: { adapter: "sails-mongo", url: "mongodb://{replicaSet1}:{port},{replicaSet2}:{port},{replicaSetN}:{port}/{dbName}?replSet={replicaSetName}&readPreference=nearest&slaveOk=true" }