sails.js

How to make a phonegap mobile app from SailsJS

我的梦境 提交于 2019-12-01 21:00:28
I've been learning to use NodeJS and SailsJS just this day and now I have a created a basic web app with user signup and list system. It is basically almost exactly the same as this: http://activityoverlord.herokuapp.com/ Now, since I have read from the official SailsJS documentation that it could be also be on phonegap using "sails build" that will output a "www" folder. -> https://github.com/coderaven/sails-docs/blob/master/What-Is-Sails.md Now, all I'm seeing are the javascript in the linker folder without the views and whatnots. I wonder how would I have exactly the same ui and

Change sails.js EJS views to use .html extensions instead of .ejs extensions?

怎甘沉沦 提交于 2019-12-01 17:57:27
Is it possible to configure sails.js apps to use .html extentions rather than .ejs (but still use the ejs view engine )? sails new app creates ./views/home/index.ejs and ./views/layout.ejs . I'd like to change the extensions to .html but keep everything else working the same way. ie: I would now have ./views/home/index.html and ./views/layout.html , and the home page would still be injected into the layout page, as per normal. How can I configure this please? In your config/views.js : engine: { ext: 'html', fn: require('ejs').renderFile }, Seems though that the future support for this feature

How to get current domain address in sails.js

折月煮酒 提交于 2019-12-01 17:35:50
问题 I trying to get current web address using sails.js. I tried the following: req.param('host') and req.param('X-Forwarded-Protocol') returns undefined. req.headers.host returns localhost. but my domain is not localhost. How to get it ?? 回答1: Just to preface this answer: there is no reliable, cross-platform way to automatically detect the external URL of a running Sails app (or any other Node app). The getBaseUrl() method described below uses a combination of user-supplied and default

Sails.js/Waterline populate deep nested association

自闭症网瘾萝莉.ら 提交于 2019-12-01 15:28:25
I understand that there is no built-in way in Sails.js/Waterline of populating deep nested associations yet, so I am trying to use bluebird promises to accomplish that but I'm running into a problem. I'm successfully retrieving the user, and all the posts (populated with the images collection) associated with it (console.log shows me that everything is filled properly). However, when I override the property "post" of the user and try to assign the fully populated posts retrieved before, it does not fill properly the images property of Post.js. It is like the ORM is preventing the image

How to use Model.query() with promises in SailsJS/Waterline?

你。 提交于 2019-12-01 15:24:11
I'm having issues with Sails.JS 0.9.8. I would like to use promises with the Model.query() function (I use sails-mysql adapter). This code will work : User.findOne({ email: email }) .then(function(user) { console.log(user); }); but this one won't User.query("SELECT email FROM user WHERE email = ?", [ email ])) .then(function(err, rows) { console.log(rows); }) I get undefined for both 'err' and 'rows'. Is it just not implemented or I am doing something wrong ? If not implemented, is there any alternative to use promises with .query() ? Thank you in advance You can promisify(User.query) yourself

Unique property fails in Sails.js

﹥>﹥吖頭↗ 提交于 2019-12-01 15:19:28
The following code represents an Account Model in Sails.js v0.9.4 . module.exports = { attributes: { email: { type: 'email', unique: true, required: true }, password:{ type: 'string', minLength: 6, maxLength: 15, required:true } } }; When I send two POSTS and a PUT request via Postman to localhost:8080/account, the unique property of the email fails. Specifically, I send the following HTTP requests from Postman: POST http://localhost:8080/account?email=foo@gmail.com&password=123456 POST http://localhost:8080/account?email=bar@gmail.com&password=123456 PUT http://localhost:8080/account?id=1

How to use Model.query() with promises in SailsJS/Waterline?

烈酒焚心 提交于 2019-12-01 14:24:37
问题 I'm having issues with Sails.JS 0.9.8. I would like to use promises with the Model.query() function (I use sails-mysql adapter). This code will work : User.findOne({ email: email }) .then(function(user) { console.log(user); }); but this one won't User.query("SELECT email FROM user WHERE email = ?", [ email ])) .then(function(err, rows) { console.log(rows); }) I get undefined for both 'err' and 'rows'. Is it just not implemented or I am doing something wrong ? If not implemented, is there any

Is there a bettery way to work with nested(associated) models in Sails JS?

守給你的承諾、 提交于 2019-12-01 14:07:27
I've connected my SailsJs app to a Mongodb database. I'm working on an analytic application. These are the major models in my application: User Project Report Event A user can have many projects, a project can have many reports and a report can have many events. I have created these relations using collection and model properties of my models attributes. My problem is why is it so hard to find events of specific user? I wish I could do this: User. find({id: id}). populate('projects'). populate('reports'). populate('events'). then(function (eventsOfMyUser) { }); but since only projects is an

How to use “await” in sails when creating a new record

て烟熏妆下的殇ゞ 提交于 2019-12-01 10:58:30
I want to use "await" According to the sails documentation I act as follows: https://sailsjs.com/documentation/reference/waterline-orm/models/create create: function (req, res, next) { var new_place = await Place.create({...}, function place_created(err, XX){ if(err && err.invalidAttributes) { return res.json({'status':false, 'errors':err.Errors}); } }).fetch(); if(new_place){ console.log(new_place); res.json({'status':true,'result':new_place}); } }, But I get the following Error: var new_place = await Place.create({...}, function place_created(err, XX){ ^^^^^ SyntaxError: await is only valid

How do I authenticate access to assets folder in sails.js

你离开我真会死。 提交于 2019-12-01 09:42:34
I am already using passport to authenticate users. I added kibana 3 to the assets folder and want users to access it only if they are authenticated. how do i do this ? sgress454 The assets folder is intended for publicly-available files, like your images and Javascripts. If you want to protect those files, you can either override the default www middleware in Sails, which activates the Express static handler to servet those files (see details on overriding default middleware in this answer ), or save the files you want to protect in a different location and use a controller action to serve