sails.js

Upload camera file using angular js to sails.js server

故事扮演 提交于 2019-12-11 08:11:38
问题 I'm trying to make a simple file upload using angular and sails.i am fairly new to all of these technolegies.could any of you please tell me what is wrong with my code? I have created an api called file using the command: "sails generate api file" in my sails server and in the controller i pasted this code(https://github.com/sails101/file-uploads/blob/master/api/controllers/FileController.js#L15): /** * FileController * * @description :: Server-side logic for managing files * @help :: See

TypeError: Cannot read property '0' of null

早过忘川 提交于 2019-12-11 07:58:38
问题 I'm working on a NodeJS Project that uses Sails.js as a framework. What I'm trying to accomplish is a permissions system where the permissions per group are set by Check Boxes, I'm using a typical form with AngularJS. When I click my "Sumbit" button it throws this error at my Browser's console: angular.1.3.js:11594 TypeError: Cannot read property '0' of null at $parseFunctionCall (angular.1.3.js:12333) at callback (angular.1.3.js:22949) at Scope.$eval (angular.1.3.js:14383) at Scope.$apply

Cannot update attributes in Sails.js model instance

只愿长相守 提交于 2019-12-11 07:56:51
问题 After updating to Sail.js 0.10.1, I've been getting an error while trying to update attribute fields of a specific instance of a model. I've tried doing User.find() as well, then setting user.attribute = someValue, and then calling user.save(), and this very same error occurred. Here is the relevant code: // TODO: Save user params (for edit/updates) save: function(req, res) { var params = req.params.all(), updateParams = {}; if (params['publicKey'] != '') { sails.log.debug('Updating public

Upon updating, how to compare a model instance with its former state

霸气de小男生 提交于 2019-12-11 07:51:46
问题 I'm using Sails.js v0.10.5, but this probably applies to more general MVC lifecycle logics (Ruby on Rails?). I have two models, say Foo and Baz , linked with a one-to-one association. Each time that data in a Foo instance changes, some heavy operations must be carried out on a Baz model instance, like the costlyRoutine method shown below. // api/model/Foo.js module.exports { attributes: { name: 'string', data: 'json', baz: { model: 'Baz' } }, updateBaz: function(criteria,cb) { Foo.findOne(

Sails.js how to modify routes to interprate comma separated list of ids

喜夏-厌秋 提交于 2019-12-11 07:48:20
问题 According to some JSON API specifciations, such as http://jsonapi.org/format/#urls-individual-resources, the server should interpret a GET request to /myResources/1,2,3,4,5. Right now the Sails.js router sends this to the findOne action. What is the best way to get this to be handled properly? I think ideally the router should interpret /1,2,3,4,5 in the same way it would interpret ?ids[1,2,3,4,5] , but I realize this may not be trivial. Another option is to add a policy to all findOne

npm ERR! Cannot read property 'pause' of undefined --Bluemix

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 07:18:51
问题 I am trying to deploy a Sails.js app to Bluemix and we are getting the following error during the deploy stage in the toolchain on Bluemix (When the CF PUSH command is called): npm ERR! Cannot read property 'pause' of undefined I understand the trace goes to the npm-error.log file, however, I haven't been able to get to it as we cannot ssh in to see whats in the file as the application is in its "off" state after a bad deploy. This same code was successfully deployed with both Cf push {app

fetch POST fails on post json body with sails.js

大城市里の小女人 提交于 2019-12-11 06:48:40
问题 I'm getting the following error within the body-parser when I try to POST a simple json body in to my controller using fetch 1] error: Unable to parse HTTP body- error occurred :: 'SyntaxError: `Unexpected token -\n at parse (/project/node_modules/body-parser/lib/types/json.js:83:15)\n at /project/node_modules/body-parser/lib/read.js:116:18\n at invokeCallback (/project/node_modules/raw-body/index.js:262:16)\n at done (/project/node_modules/raw-body/index.js:251:7)\n at IncomingMessage.onEnd

Safe to store complete user info in session with Sails.js?

不羁的心 提交于 2019-12-11 06:06:39
问题 I'm building a Sails.js app that includes a user login. As the documentation instructs, when a user signs in, the session records her id in the session accordingly: req.session.userId = createdUser.id; In most of the examples, each route performs a lookup on this ID, if it's present, and sends the authenticated user to the view if found. This strikes me as very inefficient. EVERY view needs to know if there's a signed-in user in order to display her name in the upper left corner. So, if I

Handling relationships in Mongo and Sails?

*爱你&永不变心* 提交于 2019-12-11 04:55:29
问题 I'm having a bit of a nightmare at the moment trying to figure out relationships in Mongo and Sailsjs. At the moment, I have 3 models. User, Photo and Category: User attributes: { username : { type: 'string', unique: true }, first : { type: 'string', required: true }, last : { type: 'string', required: true }, email : { type: 'email', unique: true }, photos : { collection: 'photo', via: 'user' }, passports : { collection: 'passport', via: 'user' }, shareNum : { type: 'integer'} } Photo

Cannot connect to docker mongo

↘锁芯ラ 提交于 2019-12-11 04:33:11
问题 I am setting up a project using sane with docker. After creating the project to use mongodb and createing a resource I tried running it, but got an error reporting that the server container could not connect to mongo. I then tried just running fig up to see if it was a fig problem and got the same error. Here is my fig.yml (irrelevant comments removed): db: image: mongo:latest ports: - "27017:27017" server: image: artificial/docker-sails:stable-pm2 command: sails lift volumes: - server/: