sails.js

get Selected fields in .populate() waterline-postgresql .populate('fieldName',{select:[]})

空扰寡人 提交于 2019-12-07 12:44:46
问题 select query is not working in .populate() of waterline-postgresql. Model.find(query).populate(assoc.alias,{select:['field1','field2']}); This is not working in waterline-postgresql adapter. Is this not supported or Am I making any mistake? 回答1: select is not supported in .populate(). You can see this github issue. In populate select is not working currently. This is feature request and it is open issue. hope in next release waterline team will introduce this feature. 回答2: Since there's no

Hosting sails.js application from subdirectory

帅比萌擦擦* 提交于 2019-12-07 12:28:58
问题 Due to certain restrictions, I need to host my application from a subdirectory (e.g. hostname.domain.com/mysailsapp). The webserver is nginx and set to proxy connections to sails/node. The issue I'm facing is that grunt automatically builds in the links to include frontend javascript/css/images/etc, but the entire sails app is expecting to be at the root level. Everything works fine when I connect directly to sails via port 1337 as sails is at the root, but when connecting though the

Sails.js Waterlock /auth/register causes error 500

一笑奈何 提交于 2019-12-07 11:29:00
问题 In trying to make Waterlock not to create new user on login. When I set createOnNotFound to false and try to use http://localhost:1337/auth/register?email=a@s.d&password=12345678 to register a new user. I've got 500 error: error: Sending 500 ("Server Error") response: TypeError: undefined is not a function at Object.module.exports (D:\temp\sails-waterlock\node_modules\waterlock\lib\controllers\actions\register.js:25:44) at bound (C:\Users\sandres\AppData\Roaming\npm\node_modules\sails\node

Sails.js :remove bodyparser middleware for a specific route

好久不见. 提交于 2019-12-07 09:59:34
Is there any way to remove middleware for a particular route currently all the middlewares are listed in http.js file [ 'startRequestTimer', 'cookieParser', 'session', 'bodyParser', 'passportInit', 'passportSession', 'myRequestLogger', 'handleBodyParserError', 'compress', 'methodOverride', 'poweredBy', 'router', 'www', 'favicon', '404', '500' ] I want to remove the bodyParser middleware for a particular route Is it possible with sails.js?? There's no mechanism for doing this declaratively, but yes, you can disable a middleware on a per-route basis. You would do it by overriding the middleware

Can't find records in Waterline by date/time

半世苍凉 提交于 2019-12-07 09:36:29
问题 how compare a datetime in sails.js Model? here it is what i did but without luck. var _date = moment().format('YYYY-MM-DDTHH:mm:ss.SSS') + 'Z'; Game.find({ where:{ active: true, start: { '>=' : _date } }, limit: 1, sort: 'start asc' }, function(err, game) { console.log('ERROR: ' + err); console.log('Game OBJ' + game.toString()); }); 回答1: The datetime type is transformed into an actual Javascript date in Waterline (the Sails ORM). So it needs to be compared against a date object, not a string.

Aborted upload causes Sails js/Skipper to crash

那年仲夏 提交于 2019-12-07 06:17:09
问题 Ref: https://github.com/balderdashy/skipper/issues/49 Adapter: skipper-gridfs Basic controller code: req.file('fileTest') .upload({ // You can apply a file upload limit (in bytes) maxBytes: maxUpload, adapter: require('skipper-gridfs'), uri: bucketConnect, saveAs : function (__newFileStream,cb) { cb(null, __newFileStream.filename); } }, function whenDone(err, uploadedFiles) { if (err) { var error = { "status": 500, "error" : err }; return res.serverError(error); }else { I have a jQuery-File

How to test controller using mocha in Sails?

落花浮王杯 提交于 2019-12-07 05:34:41
问题 I have the following Controller for my login page: // Authentication Controller // the basics of Passport.js to work. var AuthController = { // localhost:1337/login Render the login page // <form role="form" action="/auth/local" method="post"> // <input type="text" name="identifier" placeholder="Username or Email"> // <input type="password" name="password" placeholder="Password"> // <button type="submit">Sign in</button> // </form> login: function(req, res) { var strategies = sails.config

Restangular response and ng-repeat

倖福魔咒の 提交于 2019-12-07 05:15:45
问题 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(

sails: how to redirect after creating a model with the built-in crud operations?

喜你入骨 提交于 2019-12-07 04:02:51
问题 I'm dong some quick testing with the Sails framework for Node. I like the way default CRUD-operations work out of the box, once a model and a controller (e.g.: for user ) are created. I'm having a bit trouble with extending the basics though. Say: I've created a User-model and empty User-controller. This should give me default Rest and Crud operations. I've defined a user-signup form that does as POST to user/create . This functionality is defined out of the box. This works, but results in

Custom view/action/controller not working in Sails JS

和自甴很熟 提交于 2019-12-07 03:33:58
问题 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