sails.js

Use multiple datastore connections with Sequelize

一世执手 提交于 2019-12-13 06:12:50
问题 I've defined 2 connections in the /config/connections.js file: monolithMysql: { user: 'store_app', database: 'store', dialect: 'mysql', options: { dialect: 'mysql', host: 'dockerhost', port: 3306, logging: console.log } }, postgres: { user: 'user_app', database: 'user_authentication', dialect: 'postgres', options: { dialect: 'postgres', host: 'dockerhost', port: 8201, logging: console.log } } and in the different models I've put the property connection , so that they're distinguished, as

How to run Sails tests when a mongo oplog is watched?

不羁岁月 提交于 2019-12-13 05:06:43
问题 I added mongo-watch to my Sails application, in order to detect external changes into the mongo database, following this stackoverflow answer. This worked pretty fine, but now my automated tests fail. Probably because the barrels fixtures do not support the mongo watcher. Is there a way to set up the fixtures in Sails also when the database is watched? 回答1: You are trying to use Mongo on Travis, and it's not started by default. ;) Seems like this can be the answer to your problem: http://docs

Why does my sailsjs service return “undefined” to the calling controller action?

落爺英雄遲暮 提交于 2019-12-13 04:43:23
问题 I have to POST to an API that someone else has developed in order to obtain an authorization code, and as I have to do it in several different contexts I thought I'd move the code for handling the POST and getting the response to a service. The frustrating thing at the moment is that I seem to be getting back the value that I want from the API, but can't return it from the server to the calling sails controller. Here's the service source code: module.exports = { getVerifyCode: function(uuid,

Sails publish(Update) system does not propagate to associations

余生颓废 提交于 2019-12-13 04:42:39
问题 We are building a realtime webapp on sails 0.10.5. We have a lot of models linked through associations. For example we have a User model and a Post model, where a post always has one user. The populate makes sure that when fetching a user, we also get the posts. We tell the (websocket) client about updates using the subscribe and watch model methods in our sails controllers. However whenever a websocket client is watching both the User model ( watch and subscribe d to all users) and the Post

Sails.js - Get async data from an EJS file

南笙酒味 提交于 2019-12-13 04:42:14
问题 Are there a good way to get async data from an EJS file? Sails.js only have async methods to get data from a database. I have a collection of Pages with their associated content Values . In some cases I want to get a specific Value from another Page (e.g.: in a related page module, a navigation module...). And I need to do that server side , to keep the front-end part SEO friendly . The easier way should be to retrieve all the Pages and Values inside the controller, and then expose a function

SailsJS / Waterline - How do I use a 'string' index in models and associations?

爷,独闯天下 提交于 2019-12-13 04:24:19
问题 Newbie question here. According to https://github.com/balderdashy/waterline#indexing you cannot use a 'string' datatype as an index in Waterline due to issues with case insensitivity: There is currently an issue with adding indexes to string fields. Because Waterline performs its queries in a case insensitive manner, we are unable to use the index on a string attribute. There are some workarounds being discussed but nothing is implemented so far. This will be updated in the near future to

How do I extend sails.js library

我只是一个虾纸丫 提交于 2019-12-13 03:21:30
问题 I would like to extend sailsjs to have something similar to rails strong params i.e. req.params.limit(["email", "password", "password_confirmation"]) I have created this already as an add on, but I would like it to automatically attach to the request.params Addon: limit = function(limiters){ params = this.all(); self = Object(); limiters.forEach(function(limiter){ if(params[limiter]){ self[limiter] = params[limiter] } return self; } request: req.params.limit = limit; req.params.limit(["email"

How to add a default value from a function to the model in Sailsjs

人盡茶涼 提交于 2019-12-13 03:17:39
问题 this is my model module.exports = { attributes: { ip: { type: 'ip' }, useragent: { type: 'text' }, type: 'int' } } }; So what I need is before the record is created I need the ip and the useragent to be filled automatically from the request that comes in Is this feasible ? Thank you 回答1: You can do this via a Sails policy by setting some properties on req.options . If you have a User model and are using the blueprint create route, then in your config/policies you'd have: UserController: {

“Failed to load gRPC binary module” error when running a Sails.js application inside a Docker container

流过昼夜 提交于 2019-12-13 02:58:26
问题 I have a local Docker developer environment to build a Sails.js application. This is what my Dockerfile looks like: FROM node:8.12 LABEL Name=us.gcr.io/my-project/my-app Version=1.0.0 # Container configuration RUN npm install -g sails@1.0.2 grunt@1.0.3 nodemon@1.18.4 WORKDIR /usr/src/app COPY ./server/package.json ./package.json RUN npm install VOLUME /usr/src/app EXPOSE 1337 This is what my docker-compose.yml file looks like: version: '3.4' services: server: image: us.gcr.io/my-project/my

Generate (query) string from “where” object in waterline.js

送分小仙女□ 提交于 2019-12-13 02:38:29
问题 Using waterline.js in sails.js (0.10.5): I would like to create a 'where' string out of a where option object. For example, I have: where = { updatedAt:{">":"2015-01-08T10:00:00.000Z","<=":"2015-01-08T20:00:00.000Z"} }; and I would like to have a generated string (similar to): "WHERE updatedAt > '2015-01-08T10:00:00.000Z' AND updatedAt <= '2015-01-08T20:00:00.000Z'" Is this possible? I have the feeling it should be... 回答1: You can do date range queries using the comparison operators. Model