sails.js

sails.js Blueprint query by relations

徘徊边缘 提交于 2020-01-02 08:19:20
问题 I'm running sails 0.10.5 with postgresql support and I want to ask if there is any way to do a query to filter results by relations. For example: http://api/documents?user.role=Admin Or http://api/documents?where={"user.role": "Admin"} Or http://api/documents?where={"user.role": {"like": "%Admin%"}} Where a model Document has a belongsTo relation to User which has an attribute called role (string f.e.). I wasn't able to do such query, Am I missing something? Thank you! 回答1: I don't think that

Disable user hook in sails

♀尐吖头ヾ 提交于 2020-01-02 07:06:00
问题 I'm using sails on a project hosted on Heroku. I have a web process running a sails web server and a worker process using the same Models as the ones used by the web server. In order to make it possible I have different way to start each process with the same code : the app.js standard way a worker.js file that starts the same sails app with only the orm and services hook activated. However I have added some user hooks in a api/hooks folder that I don't want the worker to start. Is there an

Sails.js - how to update nested model

落爺英雄遲暮 提交于 2020-01-02 06:48:32
问题 attributes: { username: { type: 'email', // validated by the ORM required: true }, password: { type: 'string', required: true }, profile: { firstname: 'string', lastname: 'string', photo: 'string', birthdate: 'date', zipcode: 'integer' }, followers: 'array', followees: 'array', blocked: 'array' } I currently register the user then update profile information post-registration. How to I go about adding the profile data to this model? I read elsewhere that the push method should work, but it

Posting object array to sails causes 'TypeError: Cannot convert object to primitive value'

此生再无相见时 提交于 2020-01-02 05:39:08
问题 In my html page i am sending this post to my sails server but I cannot get to the data in my controller as the req.param() function does not return any meaningful answer. Here is the web page code $.post("http://myserver.local/calendar/batch", {"batch":[ { "start_date" : "2014-06-27T09:00:00Z", "title" : "abc", "attendees" : [ "Fred Bloggs", "Jimmy Jones", "The Queen" ], "event_id" : "123", "location" : "Horsham, United Kingdom", "end_date" : "2014-06-27T10:30:00Z" }, { "start_date" : "2014

NodeJS best practices: Errors for flow control?

故事扮演 提交于 2020-01-02 04:31:08
问题 In Node.js, should I use errors for flow control, or should I use them more like exceptions? I'm writing an authentication controller and some unit tests in Sails.js, and currently, my registration method checks to see if a user with the same username exists. If a user already exists with the username, my model method calls its callback arguments with a new Error object, like so: Model: exists: function (options, cb) { User.findOne({ where: { username: typeof options === 'Object' && options

Integrating Sails Js with Angular 2

我是研究僧i 提交于 2020-01-02 04:15:13
问题 I'm trying to integrate Angular 2 in a Sails Js application. I'm new to both. I have been following this official tutorial here. It works fine in standalone mode with a static http server but when i try to integrate into sails app i get following problems: 1 - How do i refer to angular2 js inside the local node_modules folder. Everytime i do, sails interprets it as a route and gives me a 404 for my scripts. For instance: <script src="node_modules/angular2/dist/angular2.min.js"></script> I was

Getting grunt error on sails lift

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 03:33:04
问题 I am getting this error on sails lift. Sails version : v0.10.0-rc11 error: Grunt :: module.js:340 throw err; ^ Error: Cannot find module '/home/mandeep/freelance/hellos/node_modules/sails/node_modules/grunt-cli/bin/grunt' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3 info: I have tried uninstalling grunt globally and then re-installing but its not

How to create Socket.io client in Python to talk to a Sails server

做~自己de王妃 提交于 2020-01-02 02:17:40
问题 I am running a SailsJS instance (v0.12.3) for which I have a controller MyModelController handling a WebSocket ( socket.io ) connection that is allowed if the user has authenticated. MyModelController module.exports = { /** * Socket connection */ connect: function(req, res) { /* Checks it's a socket connection request */ if (!req.isSocket) { return res.badRequest();} /* Checks it's authenticated */ if (req.session.me) { User.findOne(req.session.me, function (err, me) { if (req.param('name'))

Retrieve multiple result sets in sails js

早过忘川 提交于 2020-01-02 02:14:06
问题 I am using sails js with it sails-mssqlserver adapter. The problem with it is that if my stored procedure returns multiple result sets then I only receive one result set which is the latest of all. The same stored procedure is working fine with Java and I get to iterate over the relevant result sets. I need to know if there is some specific way to access all result sets in sails-mssqlserver? 回答1: The sails-mssqlserver adapter is a wrapper of the official Microsoft SQL Server client for Node

How to define two MySQL database connections in Sails.js

孤街醉人 提交于 2020-01-01 11:36:33
问题 Using sails.js v0.10 rc8, my app had 1 connection to a mysql database and I would liked for a given model that the data are fetched from another database. Is it possible ? If yes, how to acheive this ? Thanks 回答1: Yes, you can define multiple connections and set each model to use a different one. Please see the documentation on connections for a full review. You can set up as many connections as you need in your config/connections.js file. You can even set up multiple connections using the