sails.js

Waterline MongoDb (populated) fetched object looses its type AND prototype functions

主宰稳场 提交于 2019-12-08 02:13:51
问题 I'm using sails with mongo db over waterline. Lets say that I declare 2 models in my sails project like so : A user model @ models/User.js simplified: username: { type: 'string', unique: true }, passports: { collection: 'Passport', via: 'owner' }, aUserFunction: function(){ console.log('I'm a user function'); } and a passport model @ models/Passport.js simplified: password: { type: 'string' }, owner: { model: 'User', required: true }, aPassportFunction: function(){ console.log('I'm a passport

sails can't find layout.jade

落花浮王杯 提交于 2019-12-08 02:06:50
问题 I am starting to learn Sails (0.9.7, node 0.10.16) and running through the sailscasts episodes. I am also trying to use jade as I do so. Where I am stuck now is that sails is not finding views/layout.jade. I backed out all the jade stuff and redid with ejs and sails is not finding views/layout.ejs. As a last resort, I cloned activtyoverlord (the sailscasts app) and when I sails lift activityoverlord does not find its views/layout.ejs. Any suggests as to what I might be doing wrong? 回答1: I'm

Sails.js upgrade to v1 reverse case sensitive queries

試著忘記壹切 提交于 2019-12-08 01:32:08
问题 After upgrading to sails v1 all the requests in the controllers became case sensitive. Although this is expected, commented here: https://sailsjs.com/documentation/concepts/models-and-orm/models#?case-sensitivity, I would like to have case insensitive behavior. In my queries this is a problem and I am not able to figure out a way to make it NON case sensitive again. I am using MongoDB in production. Any kind of help or suggestion would be much appreciated. 回答1: For MongoDB we need to do a

SailsCasts User model validation

我的梦境 提交于 2019-12-07 22:15:39
问题 I am creating a sign up form by following the SailsCasts Youtube view by Ponzi Coder but I am having issues with the User model validation. If I take out the validation rules I am able to submit the form but I get the warnings below when I put the rules back in. Also, when I am able to submit it, only the ID and the CreatedAt are returned, nothing else: { "error": "E_VALIDATION", "status": 400, "summary": "3 attributes are invalid", "model": "User", "invalidAttributes": { "name": [ { "rule":

Deploying a NodeJS App to Azure Websites fails on installing NPM packages from pagages.json from deploy.cmd?

北战南征 提交于 2019-12-07 20:16:29
I'm trying to push a local GIT repository to my Azure Website using .deployment & deploy.cmd. The problem is that when the script tries to install NPM packages it fails after about half is installed. I have tried a lot of things but can't get it to work. I would appriciate if any of you have any idea of why this is not working? This is my code: package.json { "name": "api", "private": true, "version": "0.1.0", "description": "Backend API", "keywords": [], "main": "app.js", "repository": "", "author": "Frej (frej@example.com)", "license": "", "scripts": { "start": "node app.js", "debug": "node

Call REST API in Sails js

一个人想着一个人 提交于 2019-12-07 17:11:58
问题 Im using Sails js. I dont know how to call a REST api and get the response data. My Controller: var request = require('request'); var http = require('http'); var https = require('https'); module.exports = { main: function(req, res){ var rs = "Someone"; var options = { hostname: 'thomas-bayer.com', port: 80, path: '/sqlrest', method: 'GET' }; http.request(options, function(response) { sails.log.debug('log:'+response); rs = response; }); res.send("Hello "+ rs); } }; I cant get the response data

access base http server of sails.js

爱⌒轻易说出口 提交于 2019-12-07 16:51:58
问题 Hi is there a way to access the base http server context of sails? I want to use binaryJS in my app and In the gettig started guide they are talking about creating the server at your own, it you have an existing express app with the following line: var server = http.createServer(app).listen(9000); than I could use the following binaryJS command: // Create a BinaryServer attached to our existing server var binaryserver = new BinaryServer({server: server, path: '/binary-endpoint'}); thank you

Using local.js to store sails-mysql password

耗尽温柔 提交于 2019-12-07 15:37:37
问题 I'm trying to use mysql as my database, but I can't figure out how to get my config/adapters.js to use mysql information in config/local.js to connect. What's the correct way to store the connection information so that sails-mysql can connect? 回答1: config/local.js is merged on top of all other configuration. So you can just put your own adapters key in there: { adapters: { default: 'myLocalAdapter', myLocalAdapter: { module: 'sails-mysql', host: 'localhost', user: 'root', password: 'password'

sails.js 0.10.0-rc4 cannot flash message to ejs view

徘徊边缘 提交于 2019-12-07 14:04:48
问题 In server js if (!user) { if (isEmail) { req.flash('error', 'Error.Passport.Email.NotFound'); sails.log.warn('User Email not fond.'); } else { req.flash('error', 'Error.Passport.Username.NotFound'); sails.log.warn('User name not found.'); } ejs view <form role="form" action="/auth/local" method="post"> <input type="text" name="identifier" placeholder="Username or Email"> <input type="password" name="password" placeholder="Password"> <button type="submit">Sign in</button> </form> <% if (typeof

How to count association size with waterline/sails?

只谈情不闲聊 提交于 2019-12-07 13:33:20
问题 Using sails 0.10.5/waterline 0.10.15: I cannot find an answer to a simple question: how to count the elements of an association without using populate() (which would load all data). Let take a simple many2many relation with via: User: attributes: { following: { collection: 'user', via: 'follower', dominant: true }, follower: { collection: 'user', via: 'following' } Now I need the size of the collections. Currently I try User.findById(1).populateAll().exec(function(err, user) { // count of