sails.js

How to make JQuery file upload plugin call backend only once for all the files in an upload?

谁说胖子不能爱 提交于 2019-11-29 16:09:16
I'm using sails.js to build a website. I have a model named timeline . It has some text fields along with a collection named pictures . Each timeline can have multiple pictures . I want to update all these fields at once when user clicks save . I'm using JQuery file uploader to help multifile upload. Problem is, JQuery file upload calls my backend file-uploader service once for each picture uploaded. I need to update the other text fields only once and they need to be updated before the pictures records get created since each picture needs to have a timeline ID associated with them. Is async

Sails.js populate with where

爷,独闯天下 提交于 2019-11-29 15:21:40
I need to select users with dogs (pets with type equal 'dog') var User = Waterline.Collection.extend({ identity: 'user', attributes: { firstName: 'string', lastName: 'string', pets: { collection: 'pet', via: 'owner' } } }); var Pet = Waterline.Collection.extend({ identity: 'pet', attributes: { type: 'string', name: 'string', owner: { model: 'user' } } }); I didn't find any examples, I tried like this User.find().populate('pets', {type: 'dog'}).exec(err, users) ... and this User.find().where({'pets.type': 'dog'}).populate('pets').exec(err, users) ... but that does not work Would be greate if

Best way to migrate table changes to production sailsjs tables

瘦欲@ 提交于 2019-11-29 15:09:11
问题 I just lost 11,000 records from my database just running the command for sailsjs without the --prod part in it, So I thought I should ask whats the best way to change the tables on production server when the Model.js has been changed ? Thanks 回答1: Automated migration should never be done in production. This a common-sense practice that applies to any production system with important data. There are a few solutions available for migrating a sails.js database. sails-db-migrate: db-migrate

Node.js (sails.js) wysiwyg editor - images

旧街凉风 提交于 2019-11-29 15:04:12
问题 Is there a way to use any WYSIWYG/html editor in the sails app? I can't find any manuals to do that. Seems like Mercury is well-supported in Node but I can't find a way to adapt sails for it either. :( Please guide me OK now, it turned up to be easy to connect TinyMCE (just as easy as described on http://www.tinymce.com/wiki.php/Installation ). So now another major question comes out: is there any Node.js connector to any editor for uploading images and stuff? Or just how can I allow user to

Where is title or app name for sails.js (using node.js and express.js)?

▼魔方 西西 提交于 2019-11-29 14:30:52
问题 I'm trying to change my websites name. Can't find where I can set title or app name. 回答1: You can create any file in config/ directory, for example config/app.js which contains comething like this: module.exports = { appName : 'My App' }; Any property of exported object become an option of Sails` config. appName property is used as application title. For example, in default layout: <title><%- title %></title> where title === sails.config.appName === 'My App' By default appName config variable

Image not showing immediately after uploading in sails.js

北慕城南 提交于 2019-11-29 14:02:35
In my application ,I have stored uploaded images to folder ./assets/uploads. I am using easyimage and imagemagick for storing the images. In my application, after uploading the images, it should show the new uploaded image. But it is not displayed even if the page is refreshed. But when i do sails lift , the image is shown. How to show image immediately after uploading the image? Thanks a lot! It's a totally normal situation, because of the way Sails works with the assets. The thing is that upon sails lift the assets are being copied (including directory structure and symlinks) from ./assets

Chaining waterline calls with Promises

不打扰是莪最后的温柔 提交于 2019-11-29 12:11:38
问题 I have been hitting my head off a wall on this for the last 3 days. I am using sailsjs & the waterline ORM that comes bundled. I want to run DB calls one after an other. I know I can do this by nesting inside "then" calls but it just looks wrong. I have gone over the Q documentation and tutorials several times but I still don't get how to connect and fire "then" calls from existing Promises sequentially :( I want to: create a user create a action link the user & action update the user update

Uploading multiple files with Sails.js 0.10 and Skipper using Dropzone.js

北战南征 提交于 2019-11-29 10:56:08
I have an issue with multiple file upload in my sails app. I am trying to implement multiple file upload with Dropzone.js and my backend is Sails v0.10.0-rc8. Now when I upload some files via dropzone, I see that in case of multiple upload it sends the files with separate params in the request. The param names are 'photo[0]', 'photo[1]', 'photo[2]',... . I am getting the files in controller like this: req.file(file).upload(function (err, files) { // save the file }); But when there is more then one file submitted, the request is being passed to controller before all files are parsed and stored

Sails.js flash message for user registration

主宰稳场 提交于 2019-11-29 10:35:29
问题 I am following Sail.js tutorial from http://irlnathan.github.io/sailscasts/blog/2013/08/27/building-a-sails-application-ep4-handling-validation-errors-with-a-flash-message/ However I ran into a small problem. In the tutorial the author uses registration files inside his user folder and assigns routes in the user controller. He then sends validation errors using flash to the user. However in my project, the registration files lies in the root folder and I assign the routes from the routes.js

Create subfolders in Sails.js /api/controllers

故事扮演 提交于 2019-11-29 10:07:50
here is my problem: I would like to create some subfolders inside /api/controllers in order to organize my source code. My problem there is that as soon as I create a new folder, blueprint api / routes / actions don't seem to work anymore. From all my tests if I change /api/controller/UserController.js to /api/controller/newpath/UserController.js I can't get the beauty of blueprint working anymore. Is there any way to do that? Thanks Emmanuel Meeker You can set this up. Its a bit undocumented, but you can setup a "_config" object on your controller api/controllers/subFolder/YourController.js .