sails.js

SELECT and UPDATE multiple records in oriento / orientjs and transaction in waterline

做~自己de王妃 提交于 2019-12-22 01:49:25
问题 How can I select or update multiple records in oriento? Like in waterline we can offersModel.update({id:items_ids,status:INACTIVE},{status:ACTIVE}) But in waterline transaction is not available. So I want to use : var db = offersModel.getDB(); var trans = db.begin(); trans.update('offers') .set({status:INACTIVE}) .where({id:items_ids,status:ENM.SELLING_STATUS.ACTIVE})//.exec() .then(function(offers){ if (offers.length != items_ids.length) {trans.rollback(); /* send error here*/} else trans

Filtering socket.io subscriptions

╄→гoц情女王★ 提交于 2019-12-21 23:56:39
问题 Imagine I have a User model and also a Message model. User has many messages. Then in the client I do a: io.socket.get('/user/2/messages'.... I get all my user messages and there is no problem trying to get someones else messages because I have a policy for that. Good. I want to listen if the user has new messages, if I do a: io.socket.on('message') I get every message created, mine or not mine. So: Can I listen just for MY messages? AKA listen for associated messages but not all of them.

Can I deploy Sailsjs to AppHarbor or Heroku?

孤街醉人 提交于 2019-12-21 21:46:12
问题 AppHarbor supports Node using iisnode. Can I deploy my Sails.js app to AppHarbor at this time, and if so, how? I honestly have no idea what I'm doing with a node deploy but I'm trying to follow along with what I'm reading online. When I deploy my code out to my repo and AppHarbor builds it I get the following error: The current identity (...) does not have write access to 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files'. 回答1: UPDATE (September 2013) There is an updated

Sails: 404 pages won't use the default layout?

扶醉桌前 提交于 2019-12-21 20:48:58
问题 In sails.js, all files that are in the views folder use layout.ejs as their template. Error pages like 404.ejs won't use layout.ejs for some reason. I couldn't find any setting for that, can I change it? Thanks! A link to the repository, if needed: http://github.com/ronenteva/MySkills 回答1: Sails v0.10.x uses the notFound response to serve the 404 page, equivalent to calling res.notFound() in a controller action. A default response handler is provided for you in api/responses/notFound.js , but

Tracking user online/offline status in sails.js

泄露秘密 提交于 2019-12-21 20:39:29
问题 I have to find out the user status ie whether the user is online/offline using websockets in sails.js in my web application. Please help me . Thanks a lot 回答1: Starting with Sails v0.9.8, you can use the onConnect and onDisconnect functions in config/sockets.js to execute some code whenever a socket connects or disconnects from the system. The functions give you access to the session, so you can use that to keep track of the user, but keep in mind that just because a socket disconnects, it

SailsJS, SocketIO, not getting messages

百般思念 提交于 2019-12-21 20:29:38
问题 I have a simple login script. I created a method in the SessionController called create to handle logins. I do all the needed validation and then set the user as active and save them. I also use User.publishUpdate() to send the message back to the client. The problem is that I recieve no messages at all. When the page is loaded I call User.subscribe(req.socket, users); for all users so they are all subscribed. Not really sure why the messages aren't sent. I am using sails 0.10.0. This is the

Sailsjs/waterline specify number of decimal places in model

假装没事ソ 提交于 2019-12-21 19:54:49
问题 How do I tell my sails model that I want some specific number decimal places for a type: 'float' attribute? Like decimalPlaces: 4 or something of that ilk? The problem is that when i post a value to this entry, the value on disk is truncated to the .00 (hundreds) place. Say I want: 3243.2352362 to be stored just as it is. Currently this is transformed into 3243.24 If it matters I'm using the sails-mysql adapter. 回答1: types: { decimal2: function(number){ return ((number *100)%1 === 0); } },

How to use multiple layout within a SailsJS app?

荒凉一梦 提交于 2019-12-21 12:20:27
问题 My Sails.js application have separate frontend and admin layout. My view engine is ejs . How do I use separate layouts for frontend and admin site? Can I use specific layout for each action? 回答1: From Sails.js Documentation: At least in EJS, instead of indicating your custom layout with the layout local, you must use _layoutFile: res.view({ _layoutFile: 'relativePathToYourCustomLayoutFromTheTargetView.ejs' }); The path to the layout you're wanting to use should be specified relative to the

Deep associations in sails mongo using populate method?

大城市里の小女人 提交于 2019-12-21 05:22:12
问题 I am new to sails.js and I am using "sails.js with Mongodb" . I am having problem with deep associations using populate in my sails app. I have a relationship like this: Category has many to many relationship with Article. City has one to many relationship with Areas. Article has one to one relationship with City and Areas. Category.js module.exports = { schema: true, attributes: { //add referecnce to other article Articles: { collection: 'Article', via:'ref_category_id' }, category_name: {

Disable database migrations in Sails.js for all models

戏子无情 提交于 2019-12-21 05:07:14
问题 I'm trying to figure out how to disable automatic database migrations for Models in Sails.js. I know you can set migrate: 'safe' in the model, but is there a way to specify this for all models? 回答1: Actually, there is a way to do it. ORM hooks are getting defaults from sails.config.model, so all you have to do is to create config/model.js with the following content: module.exports.model = { migrate: 'safe' } After this the migrations won't be running upon sails lift , but they will still be