sails.js

Can we do $all query in sails/waterline js?

亡梦爱人 提交于 2020-02-05 09:22:08
问题 I am using mongodb and sails/waterlinejs One of my documents has a field "participants": ["1" ,"2" ,"3"] I would like to make a mongodb query: Document.find({participants: {$all: ["1", "2"]}}) But I notice that if I do it in waterline , it returns me all the documents that contains EITHER "1" OR "2" . I would like to get BOTH "1" AND "2" Is this something that I have to do in native query? Does waterline have a doc somewhere that lists all the available operators for .find() ? Thanks 回答1: Try

passport.js doesn't work on sails socket environment

烈酒焚心 提交于 2020-01-25 00:12:06
问题 I think passport.js is a amazing framework. Unfortunately, however, it seems to be that doesn't support socket. Why I said this is that Sails framework provides http and socket. When user connected sails's service through passport.js, it doesn't matter. Accessing by socket makes error. Because socket may not support middleware? Anyway, the critical problem, I don't know how apply passport.js on socket. 回答1: Indeed, the websocket requests do not pass threw the passport middleware, but it is

Sailsjs. Best way to create (and manage) indexes on sails-mongo (mongodb)

隐身守侯 提交于 2020-01-24 15:54:25
问题 I was using sailsjs 0.12. It supported index attributes on models , also i was using npm package Sails-hooks-mongoat to create inverse indexes and so. It wasn't ideal, but it worked. Right now they dropped the index attribute and mongoat is currently unsafe and pending updates to work on Sails.js 1.0. I would like to know the best approach to: Create Indexes on new deployments. Migrate (ensure?) indexes on deployment updates. 回答1: Since you are not allowed to run 'migrate: alter' in

Sails JS complex many to many association

丶灬走出姿态 提交于 2020-01-24 12:04:01
问题 Let's assume i have Three models files author, article and publications My model.js are as follows //author.js attributes : { name : 'string', articles : { collection : 'article', via : 'authors' } } //article.js attributes : { name : 'string', authors : { collection : 'author', via : 'articles' }, publication : { model : 'publication' } } //publication.js attributes : { name : 'string', articles : { collection : 'article', via : 'publication' } } From the above association if i GET an author

Sails JS complex many to many association

耗尽温柔 提交于 2020-01-24 12:03:07
问题 Let's assume i have Three models files author, article and publications My model.js are as follows //author.js attributes : { name : 'string', articles : { collection : 'article', via : 'authors' } } //article.js attributes : { name : 'string', authors : { collection : 'author', via : 'articles' }, publication : { model : 'publication' } } //publication.js attributes : { name : 'string', articles : { collection : 'article', via : 'publication' } } From the above association if i GET an author

Sails JS complex many to many association

我是研究僧i 提交于 2020-01-24 12:02:41
问题 Let's assume i have Three models files author, article and publications My model.js are as follows //author.js attributes : { name : 'string', articles : { collection : 'article', via : 'authors' } } //article.js attributes : { name : 'string', authors : { collection : 'author', via : 'articles' }, publication : { model : 'publication' } } //publication.js attributes : { name : 'string', articles : { collection : 'article', via : 'publication' } } From the above association if i GET an author

how to define error message in sails.js

自闭症网瘾萝莉.ら 提交于 2020-01-24 06:09:07
问题 It's my first time using sails and it looks like it's good but I run into a problem, is it possible to define a custom error message in sails model validation because it looks like the error message being returned is to technical and not user friendly. Thanks Update: https://gist.github.com/mikermcneil/8366092 回答1: Here's another alternative: /** * Takes a Sails Model object (e.g. User) and a ValidationError object and translates it into a friendly * object for sending via JSON to client-side

Configure sails.js not to cache the response

拟墨画扇 提交于 2020-01-23 07:20:30
问题 I have an application on node.js using sails.js as a framework. For displaying the informations to the user I have implemented some .ejs files. When navigating using links within the app menu, I receive a "304 - Nod Modified" response. Also, within headers in the response I see Etag , If-None-Match or Expires . After reading some posts, I have added the "app.disable('etag')" statement within /config/ express.js file in the customMiddleware function and etag and if-none-match are not sent

Accessing session variables in sailsjs view

戏子无情 提交于 2020-01-23 04:44:49
问题 I am quite new to sailsjs and nodejs. I am trying to create an authentication page, wherein once a user is authenticated, I want to set req.session.user = user.id req.session.authenticated = true I then need to access these values within my main layout.ejs file. I have done so by using res.locals.user = _.clone( req.session.user ) However, I noticed that this clone method has to be called in every function of every controller so as to allow me to be able to access the user from within the

npm run custom-tests - sendHttpRequest failed non200Response

泄露秘密 提交于 2020-01-16 16:11:00
问题 I'm trying to setup some SailsJS boilerplate I'm finding on the web. My code is below, I am thinking it is due to my config in routes where I set: 'GET /.temporary/csrf/token/for/tests': { action: 'security/grant-csrf-token' } I don't have any thing in api/controllers/ for security/grant-csrf-token , do I have to generate such a thing? const sails = require('sails'); before(function(done) { // Increase the Mocha timeout so that Sails has enough time to lift, even if you have a bunch of assets