sails.js

sails.js Use session param in model

两盒软妹~` 提交于 2019-11-27 16:10:54
This is an extension of this question . In my models, every one requires a companyId to be set on creation and every one requires models to be filtered by the same session held companyid. With sails.js , I have read and understand that session is not available in the model unless I inject it using the controller, however this would require me to code all my controller/actions with something very, very repetitive. Unfortunate. I like sails.js and want to make the switch, but can anyone describe to me a better way? I'm hoping I have just missed something. sgress454 So, if I understand you

Adding custom Express middleware like jQuery-File-Upload to Sails.js

白昼怎懂夜的黑 提交于 2019-11-27 14:50:25
I'm still having difficulty understanding how to add middleware to sails.js. I've heard use policies.js, create custom policies, add to local.js, etc. So could someone please show me how exactly I would add the jquery-file-upload-middleware to a sails app. Thanks in advance This would have been very difficult in previous versions of Sails, because you had no control over the order in which custom middleware was included. In v0.10, it's just kinda difficult. Note: the following will work with the beta version of Sails (v0.10.x) , installable via npm install sails@beta . Inserting your own

sails.js access controller method from controller method

▼魔方 西西 提交于 2019-11-27 13:17:01
How come in sails you cannot access other controller methods from within another one? like this. module.exports = findStore: -> # do somthing index: -> @findStore(); # Error: undefined Compiled module.exports = { findStore: function() {}, index: function() { return this.findStore(); // Error: undefined } }; If you can't do this, then why not? how else should I be doing this... lloop Having the same problem for last few hours. I used the api/services folder. It may not be exactly what you need but it is an option. A good explanation is here. What services would one add to the api/services

Swagger Sails JS

僤鯓⒐⒋嵵緔 提交于 2019-11-27 13:02:13
问题 Any idea of how to integrate swagger , swagger-ui with a sails js project? Where can i found information about it, or about another way to comment an api generated with sails? Thanks! 回答1: I was searching for a solution for this a little over a week ago, but I found the information scattered a bit. Here's how I integrated swagger and swagger-ui with my sails 0.11.x project. 1. Install sails-swagger npm install --save sails-swagger This provides a hook that will dynamically generate the

Handle browser reload socket.io

余生颓废 提交于 2019-11-27 12:07:54
There is a way in socket.io to create a timeout in the disconnected event, then check if the user has been reconnected ? The idea is to emit data / save user state in database only if the user is not reconnected after timeout Edit : Followed @Are Wojciechowski answer, I'm done with a multi tabs & F5 flood handler https://gist.github.com/foohey/7696811 There is a socket.on('disconnect', function () { ... }); . So you can just do socket.on('disconnect', function () { setTimeout(function () { //do something }, 10000); }); EDIT 1: I get it now. So maybe you should do something like this: Client: /

Sails.js - How to inject a js file to a specific route?

妖精的绣舞 提交于 2019-11-27 10:58:59
问题 For example, I have a page /locations/map which I need to include Google Map library, and include a .js file (e.g. location.js) specifically for this page only. I want to inject these 2 files to after <!--SCRIPTS END--> this line Is it possible to do this? NOTE: I was using Sails.js v0.10 回答1: Sails uses ejs-locals in its view rendering, so you can accomplish what you want with blocks. In your layout.ejs file, underneath the <!--SCRIPTS END--> , add (for example): <%- blocks.localScripts %>

how to use sails.io.js version 0.11.3 in node server

ぐ巨炮叔叔 提交于 2019-11-27 08:40:45
问题 I would like to create a chat application in my sailjs based project, How and where can i configure the socket and related setting in the server ? I got a sample project from this repository but it is using sails v0.10 and i need to use sails v0.11.3, but v0.11.3 having many changes while using socket in Nodejs script, for example, We can't use onConnect since it is deprecated. I have tried this example, but not working this with sail v0.11.3 https://github.com/sgress454/sailsChat This is the

Sails JS Waterline join of multiple models

半城伤御伤魂 提交于 2019-11-27 07:47:03
问题 Hi i'm trying to join multiple tables with populate method, i googled and couldn't find efficient way of doing it, i do not want to query db several times to build the result, is it possible to solve it with sails version "~0.10.0-rc7" i'm building quit big project with more then hundred of tables. var co = { adapter: 'someMysqlServer', migrate:'safe', autoCreatedAt: false, autoUpdatedAt: false, autoPK:false, attributes:{ id:{ type:"int", primaryKey: true, autoIncrement: true }, code:"string"

How to properly do a Bulk upsert/update in MongoDB

孤者浪人 提交于 2019-11-27 07:44:14
问题 I'm trying to: Find a document according to a search criteria, If found, update some attributes If not insert a document with some attributes. I'm using a Bulk.unOrderedOperation as I'm also performing a single insert. And I want to do everything in one operation againast DB. However something it's causing nothing is being inserted for the update/upsert operation. This is the insert document: var lineUpPointsRoundRecord = { lineupId: lineup.id, // String totalPoints: roundPoints, // Number

Is it possible to group controllers in sails using subfolders?

浪子不回头ぞ 提交于 2019-11-27 07:03:40
问题 I'm planning to organize my controllers in sails using subfolder but I'm not sure how to do it. When I tried using like admin/PageController.js and connect it with the route I keep getting a 404 error. 回答1: You can definitely do this. The trick is, the controller identity is its path, in your case admin/PageController . So a custom route in config/routes.js would be something like: 'GET /admin/page/foo': 'admin/PageController.foo' The great thing is, automatic actions still work, so if you