Sails.js support for Node.js

Introduction

This page explains the support of the Sails.js framework.

Server

For example, create a server - app.js:

...
  // Start server
  sails.lift(rc('sails'));
...

This will give the following result:

Routes

Routes control at config/routes.js:

...
'GET /site/:idSite' : {controller: "Site", action: "getSite", rel: RelServices.REL_ENUM.GET_VIEWED_SITE},
...
'PUT /alert' : {controller: "Alert", action: "putAlert", rel: RelServices.REL_ENUM.PUT_ALERT, profile: ProfileServices.PROFILE_ENUM.OPERER},
...

Controller actions:

SiteController.js

...
self.getSite = function (req, res) {
  ...
  var promise = Site.findOne({
    idSite: idSite
  });
  ...
};

AlertController.js

...
self.putAlert = function (req, res) {
  ...
  var promise = Alert.findOne({
    alertId: alertId
  });
  ...
};

Model definition:

Site.js:

...
self.connection = 'postgresqlServer';

self.tableName = 'T_SITE';


self.attributes = {
...
}
...

Alert.js

...
self.connection = 'postgresqlServer';

self.tableName = 'T_ALERT';


self.attributes = {
...
}
...

Transaction from get operation method to database when using the SQL Analyzer :