sails.js

Restangular response and ng-repeat

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 08:36:59
I have recently started to learn angularjs using restangular to talk to my restfull API (sails). The problem I have stumbled upon is that the ng-repeat does not update after I change the list in the scope. Controller: app.controller('UsersCtrl', ['UsersSvc', '$scope', function(UsersSvc, s) { UsersSvc.getList().then(function (new_users) { s.users = new_users; }) s.destroy = function (user) { user.remove().then(function () { s.users = _.without(s.users, user); }); } }]); Service: app.factory('UsersSvc', function(Restangular) { return Restangular.all('users'); }); Template: <div ng-controller=

Custom view/action/controller not working in Sails JS

北战南征 提交于 2019-12-05 08:23:22
I must be doing something wrong, but I can't see... Basically if I create a controller/model through sails generate controller products and in the file /controllers/ProductsController I add some variables to the index action such as: index: function(req, res) { return res.view({ myOne: 'World?', myvar: 'hello???', title: 'Yeap' }) }, and when I check localhost:1337/products surely enough the variables are printed within the template. Note that I haven't added a custom view and my template file is located at views/products/index.jade (I'm using Jade rather than EJS). However if I create a

How to set local timezone in Sails.js or Express.js

℡╲_俬逩灬. 提交于 2019-12-05 08:14:00
When I create or update record on sails it write this at updateAt: updatedAt: 2014-07-06T15:00:00.000Z but I'm in GMT+2 hours (in this season) and update are performed at 16:00. I have the same problem with all datetime fields declared in my models. How can I set the right timezone on Sails (or eventually Express) ? The way I handled the problem after hours of research : Put process.env.TZ = 'UTC'; //whatever timezone you want in config/bootstrap.js nicesu I solved the problem, you should setting the MySql options file to change timezone to UTC in the config/connections.js setting at this

Sails.js 0.10.x: How to listen on localhost only?

孤街浪徒 提交于 2019-12-05 07:49:18
问题 I would like to pipe all traffic through an NGINX proxy and make sure that the node server won't be accessible directly from the outside. Node's http module has the ability to listen on a given port on localhost only, is there an option to enable sails.js to do the same? 回答1: Simply add this line: config/local.js explicitHost: process.env.HOST || 'localhost' Or you could add a policy: config/policies.js module.exports.policies = { '*': 'isLocal' } api/policies/isLocal.coffee # sessionAuth # #

AppCache misbehaving in Safari, Firefox

﹥>﹥吖頭↗ 提交于 2019-12-05 07:34:55
I'm having some major trouble with AppCache. I've got a single page application (with real URLs using using Page.js and loading HTML from the server on page load, (dispatch: false) It's running on Bode.js, in particular it's a Sails.js app. I've got a manifest file in the HTML tag of the layout. The manifest file has been tested repeatedly and everything checks out. It works flawlessly in Chrome. Even in Safari, it shows up in the inspector correctly and has a list of the assets listed in the file. So far so good. However, when offline, Safari fails to load anything but the HTML document

sailsjs, using through relation, how to get the value of non related models?

拈花ヽ惹草 提交于 2019-12-05 07:26:59
问题 I have 3 models named as "User, Pet and UserPet". User model "user_name" : { type: "string", required: true }, "pets" : { collection: 'pet', via: 'user', through: 'userpet' } Pet model "pet_name" : { type: "string", required: true } UserPet Model user: { model: 'user' }, pet: { model: 'pet' }, user_expected_price: { type: "float", required: true } Query used to retrieve the data User.find().populateAll().exec(function (err, data) { console.log(data); }) I can get all the data from above

Getting grunt error on sails lift

我怕爱的太早我们不能终老 提交于 2019-12-05 07:15:40
I am getting this error on sails lift. Sails version : v0.10.0-rc11 error: Grunt :: module.js:340 throw err; ^ Error: Cannot find module '/home/mandeep/freelance/hellos/node_modules/sails/node_modules/grunt-cli/bin/grunt' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3 info: I have tried uninstalling grunt globally and then re-installing but its not working Looks like something got corrupted in your Sails install. In your project directory do: npm

SailsJS & MongoDB Aggregation framework troubles with custom queries

僤鯓⒐⒋嵵緔 提交于 2019-12-05 07:04:25
问题 I'm totally new to MongoDB and come from an SQL background. I'm trying to do this : Get the top Artists, based on the number of Dubs. Data Structure : Artists = [ { "dubs": [{...},{...},{...}], "name": "The Doors", "createdAt": "2014-12-15T15:24:26.216Z", "updatedAt": "2014-12-15T15:24:26.216Z", "id": "548efd2a436c850000353f4f" }, { "dubs": [], "name": "The Beatles", "createdAt": "2014-12-15T20:30:33.922Z", "updatedAt": "2014-12-15T20:30:33.922Z", "id": "548f44e90630d50000e2d61d" }, {...} ]

Sails.js + Waterline: Many-to-Many through association

强颜欢笑 提交于 2019-12-05 06:21:13
I'm new to Sails.js (v0.10.5) and Waterline ORM. I have 3 tables in database: users (id, name), roles(id, alias) and join table users_roles(user_id, role_id). It's important not to change table names and field names in database. I want Policy entity to be a join entity between User and Role. Here is some mapping code: //User.js module.exports = { tableName: 'users', autoCreatedAt: false, autoUpdatedAt: false, attributes: { id: { type: 'integer', required: true }, name: { type: 'string' }, roles: { collection: 'role', via: 'users', through: 'policy' }, } } //Role.js module.exports = { tableName

Sails JS forbidden POST request

余生颓废 提交于 2019-12-05 05:34:00
I'm trying to learn Sails JS and obviously REST API. I've created a user model wich I think works fine (it communicates datas with my db). I've also created a signup controller with 4 needed inputs to store a new record in my user collection. (Some other datas are generated by this controller to complete the record at the moment of the registration) I would like to test this controller with POSTMAN, so I go to my routes.js and see : 'POST /api/v1/entrance/signup': { action: 'entrance/signup' }, But when i enter a POST request at 192.168.1.13:1338/api/v1/entrance/signup with my 4 needed inputs