Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 19:20
    udovichenko starred balderdashy/sails
  • 14:59
    dubesar starred balderdashy/sails
  • 00:02
    crhoover-maxar closed #7087
  • 00:02
    crhoover-maxar commented #7087
  • Sep 17 23:33

    eashaw on check-for-invalid-columnName

    Update build-schema.js (compare)

  • Sep 17 23:33

    eashaw on check-for-invalid-columnName

    (compare)

  • Sep 17 23:06
    eashaw commented #1610
  • Sep 17 21:07
    eashaw labeled #7087
  • Sep 17 21:07
    eashaw commented #7087
  • Sep 17 21:07
    mactyr edited #7178
  • Sep 17 21:06
    sailsbot commented #7178
  • Sep 17 21:06
    mactyr opened #7178
  • Sep 17 20:54
    eashaw labeled #7113
  • Sep 17 20:54
    eashaw commented #7113
  • Sep 17 20:51
    eashaw labeled #7095
  • Sep 17 20:46
    eashaw labeled #7119
  • Sep 17 20:46
    eashaw commented #7119
  • Sep 17 20:21
    eashaw labeled #7145
  • Sep 17 20:21
    eashaw commented #7145
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}
ChrisWorks
@ChrisWorks
@amadurell That did not actually work. The user is actually still created twice the user.db. (I delete the db and relift sails) My user.db looks like this:
{"$$indexCreated":{"fieldName":"username","unique":true,"sparse":false}}
{"$$indexCreated":{"fieldName":"email","unique":true,"sparse":false}}
{"username":"Admin","email":"admin@xxyz.no","createdBy":1,"owner":1,"model":11,"createdAt":1512046369924,"updatedAt":1512046369924,"name":"","organisation":null,"curbworker":false,"reqOrgAccess":false,"active":false,"activationCode":"","resetCode":"","resetCodeExpireDate":"","provider":"","preferedlanguage":"","_id":1}
{"username":"Admin","email":"admin@xxyz.no","createdBy":1,"owner":1,"model":11,"createdAt":1512046369924,"updatedAt":1512046369946,"name":"","organisation":null,"curbworker":false,"reqOrgAccess":false,"active":false,"activationCode":"","resetCode":"","resetCodeExpireDate":"","provider":"","preferedlanguage":"","_id":1}
@amadurell You can see the createdAt is the same weird, but updatedAt are different .. and _id is the same, how is that possible?
Alexandre Madurell
@amadurell
@ChrisWorks Did you lift sails --drop? (if not, before you do, back up your data). Regarding localDiskDb and Mongo, not sure how you want to handle that, but I guess once you transfer the data from one to the other, you will want to remove the reference to the former in the datastores? Or is that intended to synchronize one with the other when offline/online?
@ChrisWorks I guess you'll have to delete the duplicate entries manually in the user.db file, since they were allowed before adding the unique attribute... If you lift sails --drop everything should be erased, and the data structure recreated... otherwise, I think lift sails --alter will throw an error since those previous records are incompatible with the new data structure definition
ChrisWorks
@ChrisWorks
@amadurell I delete the full localDiskDb folder, so the user.db is created from scratch when I lift sails and is therefore completely empty. Then a hook is creating the admin user, and the User.afterCreate is called once, but 2 entries are displayed in the user.db. .... how is that possible?
Alexandre Madurell
@amadurell
@ChrisWorks Are you connected to both localDiskDB and Mongo? Did you try lifting sails with the --drop option?
ChrisWorks
@ChrisWorks
@amadurell With the --drop my user.db looks like this:
{"username":"Admin","email":"admin@xyz.no","createdBy":1,"owner":1,"model":23,"createdAt":1512047927066,"updatedAt":1512047927066,"name":"","organisation":null,"reqOrgAccess":false,"active":false,"activationCode":"","resetCode":"","resetCodeExpireDate":"","provider":"","preferedlanguage":"","_id":2}
{"username":"Admin","email":"admin@xyz.no","createdBy":1,"owner":2,"model":23,"createdAt":1512047927066,"updatedAt":1512047927080,"name":"","organisation":null,"reqOrgAccess":false,"active":false,"activationCode":"","resetCode":"","resetCodeExpireDate":"","provider":"","preferedlanguage":"","_id":2}
@amadurell There are only 2 entries in user.db but they still get the same _id (2)
@amadurell I use localDiskDb only (no mongo yet)
How can sails allow 2 entries to have the same "_id" when the id is defined like this: id: { type: 'number', columnName: '_id', autoIncrement: true, unique: true}
Alexandre Madurell
@amadurell
@ChrisWorks The only difference I see is in the owner value... but still, it shouldn't let you repeat a record with a repeated unique attribute... weird... I'm not too familiar with afterCreate unfortunately :(
ChrisWorks
@ChrisWorks
I dont where the bug is, but it could be either in my code, which uses the module sails-auth-new (for v1), which again calls passport.register :( This all worked fine on 0.12.14
@amadurell Thanks for the help anyways. :)
Alexandre Madurell
@amadurell
@ChrisWorks Just my daily quota of rubber-ducking ;) https://en.wikipedia.org/wiki/Rubber_duck_debugging
ChrisWorks
@ChrisWorks
@amadurell ha ha :smile: