Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Raj Soni
@edencorbin @martskins Hi guys we have just started sailsit and we are trying to expand. Regarding the website layout, we will be launching our new website layout by today so stay tuned. We have a fb group and twitter page, do follow us.
@soniraj This sounds great. Cant wait to have a look.
@soniraj Would you be able to structure the content by theme on the site? E.g. "Getting started with Sails", "How to structure your app", "Working with policies". As I mentioned yesterday we need a place to document best-practices and how to work with the various sails features. This would include allowing people discuss how to do a certain thing and then graduate the approach into documented pattern.
Raj Soni
@ChrisWorks do you mean to say, organize content category wise for better readability ?
Alexander Ostapenko
about changes to framework I like scheme in Ember where changes are discussed via public RFC https://github.com/emberjs/rfcs
@soniraj Yes, one thing we were discussing here yesterday was to create a lexicon for sails "how-to's". Instead of a long list of blog-posts, we would need categorize the content so users can easily find what they are looking for. (not just search for it).
"Getting started guides" -> ... "Sails and email ->" ... "Sails and databases" ... "App architecture ->" .. "Integrations with.... " ... so a topic based navigation. :)
Alexander Ostapenko
@mikermcneil does sails-mysql datastore configuration accept parameters for node-mysql driver? I'd like to know how datastore works with pool of connections to MySQL.
Tom Murphy
any luck with my query ? :)
Albert Peiró

@mikermcneil the query:


used to be case insensitive in 0.12 by default at least with disk and mongo adapters. I'm upgrading to 1.0 and need to keep it that way. How? Any reference? anyone?
In 1.0 it seems to be case sensitive now..

Raj Soni
@ChrisWorks nice idea ! once our new layout is up, we can start work on the categorization
Eden Corbin
@soniraj, another categorization request would be in the forums section. "new to sails", "errors and troubleshooting", "user tutorials", "extending sails", "sails db adapters", "looking for help", just random off the top of head ideas, it's nice that new users have a place they don't feel intimidated posting "new to sails", and that advanced users can better specify their forum topic, and lastly that some categories are clearly not intended for q & a (although the q & a format is fine to leave as it can be used as a comment system at that point) "user tutorials".
Eden Corbin
If you have async controller routes, any way to have sails auto try catch them all, so you don't have to write a try catch inside each one?
@edencorbin maybe create a function wrapper that returns a controller method and wraps the actual method in a try/catch?
function basicHandler(fn) {
    return function (req, res, next) {
      try {
            fn(req, res, next);
        } catch (err) {

// SomeController.js
module.exports = {
    someControllerMethod: basicHandler(function (req, res, next) {
       // Do un-"try/catched" stuff
actually.. i didn't even think of async there.. but it should be analogous
Alexander Ostapenko
@martskins It could be better to do with ES6-classes. To write abstract Controller class and extend your custom controllers from this class... but Sails doesn't support controllers as class instance
I've done theese scheme with sails 0.12

and my custom controllers look like:

class MembersController extends Controller {
    constructor() {

all CRUD-actions are realized in this abstract Controller class

Eden Corbin
@martskins thanks that's a great idea, I think I'll do that, should work perfectly for my use case, and trim a bunch of repeated code.
@NachtRitter that also looks like a good approach, are you saying it worked in .12 but not in 1.0.
Alexander Ostapenko

@edencorbin it works in sails 0.12 but via different "hacks" like:

class Controller {

    constructor(modelName) {
        this.model = modelName;


    _assignPublicMethods(sourse) {
        var controller = this;
        _.forEach(Object.getOwnPropertyNames(sourse), function (localName) {
            if (!controller.hasOwnProperty(localName)  && _.isFunction(sourse[localName])  && localName != 'constructor') {
                var publicName = localName.substring(1); // cut off '_' in the beginning of private method, e.g. '_create'
                controller[publicName] = sourse[localName];

I haven't tried to do this in Sails 1.0 yet

but I think I should works in Sails 1.0 also.
Eden Corbin
Okay, I'll keep digging into this, I imagine this is something that could benefit everyone working in 1.0+ async and not wanting to try catch every controller route.
Alexander Ostapenko
@edencorbin yeah, similar approaches also helps to do less mistakes or different behavior for same actions in different controllers
Rachael McNeil
@edencorbin @NachtRitter Sails/Express automatically catches errors that are thrown as long as you're using await. For handling specific errors, you might check out .intercept() and .tolerate()
Eden Corbin
@rachaelshaw wow it does, I/we were overthinking that problem, I see I can link into the function in responses/serverError, and my async errors go there automatically, perfect, thanks.
any suggestion how to test sails with avajs?
I cant get it

i'm getting this

error: Sending 500 ("Server Error") response:
UsageError: Sorry, .exec() doesn't know how to handle {...} callbacks.
Please provide a callback function when calling .exec().
| If you passed in {...} on purpose as a "switchback" (dictionary of callbacks),
| then try calling .switch() intead of .exec().
[?] See https://sailsjs.com/support for more help.

only on my remote server
anyreason why
was using windows previously, trying to deploy onto ubuntu 16.04
Alexander Ostapenko
how can I return Promise from helper?
Sachin Pachari

Hi Guys, I am trying to connect to mongo using sails adapter, and i am using trying to set auth-source as "etc/*.pem" file. but not sure how to set this up using the config/connections.js file.

Thanks in advance.

I am getting an error in v1. User.findOne( {id: user.id } ) throws an error: Cannot findOne() without specifying a more specific where clause. I thought specifying the exact ID should be specific enough, right? Anyone seen this before?
Venkat Sai Gajendrula
I am facing issue while installing sails globally

coffee-script@1.12.8 postinstall C:\Users\vesai\AppData\Roaming\npm\node_modules\sails\node_modules\csextends\node_modules\coffee-script
node --eval 'if (require("./package.json").name === "coffee-script") { var red, yellow, cyan, reset; red = yellow = cyan = reset = ""; if (!process.env.NODE_DISABLE_COLORS) { red = "\x1b[31m"; yellow = "\x1b[33m"; cyan = "\x1b[36m"; reset = "\x1b[0m"; } console.warn(red + "CoffeeScript has moved!" + reset + " Please update references to " + yellow + "\"coffee-script\"" + reset + " to use " + yellow + "\"coffeescript\"" + reset + " (no hyphen) instead."); console.warn("Also, a new major version has been released under the " + yellow + "coffeescript" + reset + " name on NPM. This new release targets modern JavaScript, with minimal breaking changes. Learn more at " + cyan + "http://coffeescript.org" + reset + "."); console.warn(""); }'


SyntaxError: Invalid or unexpected token
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Object.<anonymous> (eval-wrapper:6:22)
at Module._compile (module.js:635:30)
at evalScript (bootstrap_node.js:462:27)
at startup (bootstrap_node.js:163:9)
at bootstrap_node.js:608:3

Anyone faced with the same problem ?
Alexandre Madurell
@ChrisWorks Have you checked the records of the User model/table? If you had duplicate records on that index, or the id attribute isn't defined as unique, it would throw that error. It doesn't make sense, I know, but... just to be sure that's not the case
praveen kumar
Hi All,
I got an error in sails inversible model for sql TypeError: Cannot read property 'toLowerCase' of undefined
at Object.exports.toSailsAttribute
anyone help me?
Alexandre Madurell
@praveen4554 sounds like the instance of that model is empty. Can you copy/paste the line of your code where you have the .toLowerCase? (plus... shouldn't it be .toLowerCase()?)
praveen kumar

@amadurell my code var sim = require('sails-inverse-model');

var config = {
host: "localhost",
database: "don",
user: "root",
password: "root",
port: 3306
var folder_controllers = "";
var folder_models = "./api/models";
var folder_views = "";

sim.generatemy(config, folder_models, folder_controllers, folder_views);

@amadurell error home/infinate/raju-ui/ddnrp/swagger/ddn/node_modules/mysql/lib/protocol/Parser.js:80
throw err; // Rethrow non-MySQL errors

TypeError: Cannot read property 'toLowerCase' of undefined
at Object.exports.toSailsAttribute (/home/infinate/raju-ui/ddnrp/swagger/ddn/node_modules/sails-inverse-model/generator/mysql/compiler_mysql.js:108:14)
at transpile (/home/infinate/raju-ui/ddnrp/swagger/ddn/node_modules/sails-inverse-model/generator/mysql/compiler_mysql.js:94:18)
at /home/infinate/raju-ui/ddnrp/swagger/ddn/node_modules/sails-inverse-model/generator/mysql/compiler_mysql.js:47:28
at Query._callback (/home/infinate/raju-ui/ddnrp/swagger/ddn/node_modules/mysqldesc/lib/describing/mysql_describer.js:137:13)
at Query.Sequence.end (/home/infinate/raju-ui/ddnrp/swagger/ddn/node_modules/mysql/lib/protocol/sequences/Sequence.js:88:24)
at Query._handleFinalResultPacket (/home/infinate/raju-ui/ddnrp/swagger/ddn/node_modules/mysql/lib/protocol/sequences/Query.js:139:8)
at Query.EofPacket (/home/infinate/raju-ui/ddnrp/swagger/ddn/node_modules/mysql/lib/protocol/sequences/Query.js:123:8)
at Protocol._parsePacket (/home/infinate/raju-ui/ddnrp/swagger/ddn/node_modules/mysql/lib/protocol/Protocol.js:279:23)
at Parser.write (/home/infinate/raju-ui/ddnrp/swagger/ddn/node_modules/mysql/lib/protocol/Parser.js:76:12)
at Protocol.write (/home/infinate/raju-ui/ddnrp/swagger/ddn/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/home/infinate/raju-ui/ddnrp/swagger/ddn/node_modules/mysql/lib/Connection.js:103:28)
at emitOne (events.js:96:13)
at Socket.emit (events.js:191:7)
at readableAddChunk (_stream_readable.js:178:18)
at Socket.Readable.push (_stream_readable.js:136:10)
at TCP.onread (net.js:561:20)

Alexandre Madurell
@praveen4554 Let me try it here...
praveen kumar
@amadurell sails 0.12.14 and sails-inverse-model 2.0.5
Alexandre Madurell
@praveen4554 yup... looks like it has a bug... I'm out to lunch now, but I'll take another look later. Interesting tool (if it only worked!)