sails.js

Skipper in SailsJS (beta) image resize before upload

拈花ヽ惹草 提交于 2019-11-28 12:09:28
I'm using SailsJS (beta). I'm trying to find a way to use graphicsmagick to take the stream parsed by Skipper in SailsJS-beta to resize the image before calling the Skipper-function req.file('inputName').upload() . My goal is to take my large, original image, and resize it before uploading it. Sails beta have introduced the Skipper-file-parser which are poorly documented (at least I don't understand it). Please help me understand how to resize the image before upload. This works (code in my controller action): req.file('fileName').upload('storedImage.png', function(err, files){ // File is now

Using async.js for deep populating sails.js

梦想的初衷 提交于 2019-11-28 11:45:19
问题 I have a big issue with my function in sails.js (v12). I'm trying to get all userDetail using async (v2.3) for deep populating my user info: UserController.js: userDetail: function (req, res) { var currentUserID = authToken.getUserIDFromToken(req); async.auto({ //Find the User user: function (cb) { User .findOne({ id: req.params.id }) .populate('userFollowing') .populate('userFollower') .populate('trips', { sort: 'createdAt DESC' }) .exec(function (err, foundedUser) { if (err) { return res

jquery ajax returns success when directly executed, but returns error when attached to button, even though server response is 200 OK

守給你的承諾、 提交于 2019-11-28 10:33:00
问题 This is somewhat related to other similar questions: jquery ajax returns error but is success jquery .ajax always returns error - data being added to database Jquery Ajax Call always returns error However, my problem doesn't seem to be the data:"json" issue. My code is a simple POST request to a server and, for testing purposes, it is always returning 200 OK. If I run the jquery code directly after document ready, it works just fine and calls the success function. But if I attach it to a on(

MongoError: topology was destroyed sailsjs

送分小仙女□ 提交于 2019-11-28 10:14:43
When I try to create this error shows up: Error (E_UNKNOWN) :: Encountered an unexpected error MongoError: topology was destroyed at Server.insert (/Users/oscargallon/Documents/developer/sails/reyesmagoswebpae/node_modules/sails-mongo/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:797:49) here's my model module.exports = { attributes: { name: { type: 'string', required: true }, email: { type: 'String', required: true }, description: { type: 'string', required: true }, phonenumber: { type: 'string', required: true }, mobile: { type: 'string', required: true } } }; I

Sails.js populate with where

断了今生、忘了曾经 提交于 2019-11-28 08:41:59
问题 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({

native update in Sails with Mongo does not work with ObjectId

落爺英雄遲暮 提交于 2019-11-28 08:33:10
问题 I wonder what I am doing wrong. I use Sailsv0.10 and mongo2.6.0 and want to update an array field (using $push) in a collection via native. My model: module.exports = { schema: true, attributes: { username: { type: 'string', required: true }, pubs: { type: 'array', defaultsTo: [] }, ... My function: User.native(function (err, collection) { collection.update({username:aUsernameVariable},{$push:{pubs:aPubsVariable}}, function (err) { }); It works so far. But why does that not work as a query

Is there a way to disable waterline and use a different ORM in sails.js?

試著忘記壹切 提交于 2019-11-28 08:19:27
I'd like to replace waterline with mongoose in my sails.js application. I'm looking for the correct way to do this, but I don't see how in the documentation. Can anyone explain how to do this? Defining overrides via .sailsrc You could do this via config overrides, to be defined via .sailsrc in your project root. Basically you have to prevent the entire Waterline initialization, currently tagged as orm hook. In .sailsrc: { "hooks": { "orm": false, "pubsub": false } } You'll have to disable the pubsub hook as well - it depends on the orm hook. Relevant lines in the source: v0.10 , v0.9.8 . This

Image not showing immediately after uploading in sails.js

南楼画角 提交于 2019-11-28 07:55:22
问题 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! 回答1: It's a totally normal situation, because of the way Sails works with the assets. The thing is

Upload multiple files in angular

你说的曾经没有我的故事 提交于 2019-11-28 06:46:50
I've a situation where I've a form in which I've a row where I've two text fields entries and I've to upload a file for that row and this kind of rows can be 'N' and then there is a master files that can be entered for whole form while these are some part of the form and I've to submit all these files at once on clicking a save button. I'm kind of stuck with ng-upload it needs an api call, and I really can't have more than one api call for this form. The sample html code is below : <!DOCTYPE html> <html> <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"

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

爱⌒轻易说出口 提交于 2019-11-28 04:23:10
问题 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