Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 15:59

    eashaw on default-sort-with-.stream()

    Update stream.js (compare)

  • 15:59

    eashaw on default-sort-with-.stream()

    (compare)

  • 14:29

    rachaelshaw on v0.9.0

    (compare)

  • 14:29

    rachaelshaw on master

    0.9.0 (compare)

  • 14:05
    eashaw labeled #7160
  • 14:05
    eashaw edited #7160
  • 14:01
    eashaw commented #7158
  • 14:01

    eashaw on master

    Small text correction Change "… Merge pull request #7158 from z… (compare)

  • 14:01
    eashaw closed #7158
  • 13:23
    eashaw labeled #4749
  • 13:05
    eashaw edited #7160
  • 13:05
    sailsbot commented #7160
  • 13:05
    eashaw opened #7160
  • 12:54
    SharerMax starred balderdashy/sails
  • 12:47
    eashaw labeled #7133
  • 09:34
    jensendarren starred balderdashy/waterline
  • 09:28
    tomy0000000 starred balderdashy/sails
  • 07:45
    train860 starred balderdashy/sails
  • Aug 02 20:42
    eashaw labeled #7144
  • Aug 02 20:42
    eashaw commented #7144
ChrisWorks
@ChrisWorks
@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
@NachtRitter
@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
@bluemalkin
any luck with my query ? :)
Albert Peiró
@albertpeiro

@mikermcneil the query:

{"where":{"or":[{"name":{"contains":"su"}}]}}

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..
https://github.com/adminxhq/sails-hook-adminx/blob/sails-1.0/api/controllers/AdminXController.js#L49

Raj Soni
@soniraj
@ChrisWorks nice idea ! once our new layout is up, we can start work on the categorization
Eden Corbin
@edencorbin
@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
@edencorbin
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?
martskins
@martskins
@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) {
            console.log(err);
            res.serverError(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
@NachtRitter
@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() {
        super('Members');
    } 
}

all CRUD-actions are realized in this abstract Controller class

Eden Corbin
@edencorbin
@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
@NachtRitter

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

class Controller {

    constructor(modelName) {
        this.model = modelName;

        this._assignPublicMethods(this.__proto__.__proto___);
        this._assignPublicMethods(this.__proto__);
    }

    _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
@edencorbin
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
@NachtRitter
@edencorbin yeah, similar approaches also helps to do less mistakes or different behavior for same actions in different controllers
Rachael McNeil
@rachaelshaw
@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
@edencorbin
@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.
cacoch
@cacoch
any suggestion how to test sails with avajs?
I cant get it
Lzxe92
@Lzxe92
hmm

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
@NachtRitter
how can I return Promise from helper?
Sachin Pachari
@SachinPachari

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.

ChrisWorks
@ChrisWorks
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
@gvenkatsadi93
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(""); }'

'if
^^^

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
@amadurell
@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
@praveen4554
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
@amadurell
@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
@praveen4554

@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
@amadurell
@praveen4554 Let me try it here...
praveen kumar
@praveen4554
@amadurell sails 0.12.14 and sails-inverse-model 2.0.5
Alexandre Madurell
@amadurell
@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!)
Alexander Ostapenko
@NachtRitter
@ChrisWorks just use User.findOne(user.id) or User.findOne({ where: { id: user.id } })
praveen kumar
@praveen4554
@amadurell Thank you I am looking for your solution
ChrisWorks
@ChrisWorks
@amadurell Yes it seems that there is indeed multiple records in the localDiskDb/user.db, which should not happen of course. I may have issues defining my "id" attribute. I have this in my config\model.js
id: { type: 'number', columnName: '_id', autoIncrement: true}
I find this tricky to figure out - as this will differ from when I starting using a database. How do I handle the "id" definition when switching back and forth between localDiskDb and e.g. Mongo?
Alexandre Madurell
@amadurell
Add unique: true
@ChrisWorks So it becomes: id: { type: 'number', columnName: '_id', autoIncrement: true, unique: true}