sails.js

Sails multiple handlers for the same route

谁说我不能喝 提交于 2019-12-02 03:07:07
As the title suggests, I would like to assign multiple action handlers within different controllers for the same route in Sails Js What I have tried: "post /rest/users": [{ controller: "FirstController", action: "someAction" }, { controller: "SecondController", action: "otherAction" }] But this gives me error 51 in Sails, and neither action is reached (when debugged). I searched for this solution but I couldn't find something. I know that Sails uses Express's route middleware and I found that this can be done in Express with the following route: app.post('/users', createUser, saveToDB,

Sails multiple handlers for the same route

那年仲夏 提交于 2019-12-02 02:59:44
问题 As the title suggests, I would like to assign multiple action handlers within different controllers for the same route in Sails Js What I have tried: "post /rest/users": [{ controller: "FirstController", action: "someAction" }, { controller: "SecondController", action: "otherAction" }] But this gives me error 51 in Sails, and neither action is reached (when debugged). I searched for this solution but I couldn't find something. I know that Sails uses Express's route middleware and I found that

Sails.js - Is there intended support for a “one-way-many” association

≡放荡痞女 提交于 2019-12-02 01:40:12
I'm interested in a one-way-many association. To explain: // Dog.js module.exports = { attributes: { name: { type: 'string' }, favorateFoods: { collection: 'food', dominant: true } } }; and // Food.js module.exports = { attributes: { name: { type: 'string' }, cost: { type: 'integer' } } }; In other words, I want a Dog to be associated w/ many Food entries, but as for Food , I don't care which Dog is associated. If I actually implement the above, believe it or not it works. However, the table for the association is named in a very confusing manner - even more confusing than normal ;) dog

JSON stringify in Node JS not serializing array of objects

寵の児 提交于 2019-12-02 01:28:58
问题 I am using sails.js (node js framework). I am trying to JSON.stringify one of the objects, but when I do that it omits one of the fields (rooms array below). Here is what console.log(object) gives me: [ { rooms: [ [Object], [Object] ], state: '53df76c278999310248072c6', name: 'Sydney Center', menuItems: null, createdAt: Mon Aug 04 2014 23:42:08 GMT+0300 (Jerusalem Summer Time), updatedAt: Mon Aug 04 2014 23:42:08 GMT+0300 (Jerusalem Summer Time), id: '53dff0205c89c03428a31cee' }, { rooms: [

sailsjs still uses default database after changing it to mongodb

牧云@^-^@ 提交于 2019-12-02 00:02:38
I am new to sailsjs and currently working on project that uses sailsjs. I want to change the default database to mongodb . I did it in config/local.js like following connections: { 'defaults': 'mongo', mongo: { module: 'sails-mongo', host: 'localhost', user: '', password: '', database: 'dbName', schema: true } } After starting mongodb and tried to create some data using application(that I am working on), and then when I check that in mongodb using mongodb command line tool . It finds no data there and when I check that in application it loads all of the data from database. That means it is

what is 'info: transport end (undefined)'? in Sails.js

℡╲_俬逩灬. 提交于 2019-12-01 23:50:47
When I start the server 'sails lift', it shown debug: -------------------------------------------------------- debug: :: Mon May 05 2014 10:59:17 GMT+0700 (ICT) debug: debug: Environment : development debug: Port : 1337 debug: -------------------------------------------------------- info: handshake authorized AUcEOqQtYzXw0jBMiSbp info: handshake authorized t9Y7k4zozlyXd1nwiSbq info: transport end (socket end) info: transport end (undefined) I wonder what are those last two lines? info: transport end (socket end) info: transport end (undefined) TL;DR: If you don't want to see those messages,

ObjectID not storing hexadecimal value

三世轮回 提交于 2019-12-01 22:44:56
Originally, my Sails/Mongo was storing the ObjectID in the database as follows: "_id" : ObjectId("557077fb836bdee256004232") Not sure what changed or happened, but now new records are being stored as follows: "_id" : { "_bsontype" : "ObjectID", "id" : "UtÓ-Åß\u0010C&5", "generationTime" : 1434552692 } This is only occurring in 2 developer environments out of 6. Things I've checked: Reverted to a stable commit from last week, cleared node_modules, npm cache, etc. Re-installed and no luck. Re-installed Node/npm/MongoDB completely to ensure I'm on the latest stable version of everything... my

JSON stringify in Node JS not serializing array of objects

我们两清 提交于 2019-12-01 21:43:20
I am using sails.js (node js framework). I am trying to JSON.stringify one of the objects, but when I do that it omits one of the fields (rooms array below). Here is what console.log(object) gives me: [ { rooms: [ [Object], [Object] ], state: '53df76c278999310248072c6', name: 'Sydney Center', menuItems: null, createdAt: Mon Aug 04 2014 23:42:08 GMT+0300 (Jerusalem Summer Time), updatedAt: Mon Aug 04 2014 23:42:08 GMT+0300 (Jerusalem Summer Time), id: '53dff0205c89c03428a31cee' }, { rooms: [ [Object], [Object], [Object] ], state: '53df76c278999310248072c6', createdAt: Mon Aug 04 2014 23:43:21

Manually include assets in SailsJS 0.9.7

孤人 提交于 2019-12-01 21:34:52
I'm trying to manually include some assets in SailsJS, however I can't get them to work. They keep 404'ing. The config/routes.js comments tell me that and image in assets/images/1.png would be accessible via href="images/1.png" . The same thing doesn't seem to apply for stylesheets as <link rel="stylesheet" href="/styles/style.css"> results in a 404 not found. I saw that Sails uses a very extensive Gruntfile as of lately, but I wanted a bit more control so I ditched it. I know that breaks the automatic including of assets, but did that also break the manually insertion? :( Edit: I found in the

Conditional publish events

假装没事ソ 提交于 2019-12-01 21:00:53
Introduction I'm building a private messaging system using sails, but this question can apply to pretty much anything. I'll be using the messaging system as an example to make the question more clear. As a bit of background info, I'm working with the latest sails 0.10 RC. The problem Sails allows you to use redis for sessions and pubsub, which allows you to scale over multiple servers. This is all very neat and works brilliantly, but it leaves me with the question of how to publish events to specific connected sockets (clients) . Sometimes you wish to only publish events to participants, as is