sails.js

How to change/specify database used during runtime with Sails.js

做~自己de王妃 提交于 2019-12-10 18:23:59
问题 Sail.js has ORM, I can make queries to databases. I want to make a frontend that uses AJAX to communicate with the backend. But I want the backend to query different databases based on an id/name given with the ajax query. And it would be good to be able to add/remove those same databases during runtime. Is this possible with Sails.js? I can only find ways to have a static amount of DBs (declared in conf files). 来源: https://stackoverflow.com/questions/32797745/how-to-change-specify-database

Sails.js application not refreshing files from assets after start

ε祈祈猫儿з 提交于 2019-12-10 18:07:24
问题 I have a Sails.JS application with Angular.JS front-end. The angular files are stored in /assets/linker and they are injected properly on start. My issue is that when I change css or js file from assets the change doesn't appear on the server, the loaded js file is the same as when the server started. I tried to clear my browser cache and tried in another browser, but still the same. I also tried to run the application with forever -w and nodemon , but still nothing. The application is in dev

How to upload files - sails.js

不羁岁月 提交于 2019-12-10 17:15:18
问题 I can download images and pdf, but I can't download documents files (.doc .pptx .odt ...) when download Documents(.doc .pptx .odt ...) are downloaded as .ZIP only XML files. What I can do? I'm using : fill out upload file docs upload: function (req, res) { req .file('avatar') .upload({ maxBytes: 10000000 }, function whenDone(err, uploadedFiles) { if (err) { return res.negotiate(err); } // Generate a unique URL where the avatar can be downloaded. avatarUrl = require('util').format('%s/user

configure sails server to work with html5Mode?

霸气de小男生 提交于 2019-12-10 17:14:43
问题 I have an angular-sails app where I want to remove the hash from urls I added this to my client app.config $locationProvider.html5Mode(true); and the routing works until I refresh the page. navigating to http://localhost:1337/about works. I refresh and get { "status": 404 } from sails server. How do I configure sails to work with angularjs html5Mode? 回答1: To use HTML5Mode you need your server setup to only provide the your root (or "index.html") file. "web.com/index.html". In my opinion this

Sails.js intellisense in Webstorm

独自空忆成欢 提交于 2019-12-10 15:37:34
问题 is there any available intellisense for Webstorm for Sails.js app? In all my controllers, I get message that the model is undefined, even though it works perfectly. The same goes with calling services. 回答1: This framework is not currently supported - please vote for http://youtrack.jetbrains.com/issue/WEB-11025. And WebStorm doesn't support its way of loading modules and thus can't provide intellisense 回答2: i know this is a little old, but what i ended up doing was first naming all "modules

Fetch results from model in Waterline if property is defined

做~自己de王妃 提交于 2019-12-10 14:22:03
问题 I've got a model where not every property is required. I'd like to query the model and return all instances where the property is defined. Here's what I think the code should look like, but it doesn't work. Any ideas or links to some detailed documentation? MyModel.find() .where({ "propertyThatMayExist" : { "!=" : undefined } }); Thanks a bunch in advance! 回答1: The easiest way would be to test against null . The correct operator is ! or not : MyModel.find().where({propertyThatMayExist: {'!':

Does Sails.js or Meteor.js work with ArangoDB or OrientDB?

拥有回忆 提交于 2019-12-10 13:18:20
问题 I'm planning to work on a social site and I would like to leverage both a document and graph database for all of the desired features. Is there a way to get Meteor.js or Sail.js (or any better) to work with ArangoDB or OrientDB? Or should I just stick with the bundled MongoDB and integrate something like allegrograph DB? 回答1: Sails.js has support for both of the databases you mention: https://www.npmjs.com/package/sails-orientdb https://github.com/rosmo/sails-arangodb In addition to MongoDB,

How to generate model from exists database in Sails JS?

雨燕双飞 提交于 2019-12-10 12:59:18
问题 I begin with SailsJS and MySQL , and I have many tables in my database. So, I don't know that in SailsJS has a tool to generate models from database like Database First in Entity Framework ( ASP ) 回答1: You should use, it's very good to auto generate model base DB existing. https://www.npmjs.com/package/sails-generate-models 回答2: SailsJS does not have such a tool implemented. Though, it should not be hard to create that yourself since MySQL's SHOW COLUMNS FROM table works quite well. Then you

sailsjs beforeCreate is not triggered

◇◆丶佛笑我妖孽 提交于 2019-12-10 12:59:08
问题 I have a blank sails 0.9.8 app with a very basic model: module.exports = { attributes: { nickname: 'string', encryptedPassword: 'string', beforeCreate: function(values, next){ values.encryptedPassword = "123"; next(); } } }; When I create a new User from the console, the beforeCreate method is not called, thus no encryptedPassword created. I'm sure I'm missing a little something here but cannot find out what. Any idea ? 回答1: You have to place beforeCreate outside of the attributes. See https:

Sails: increase bodyParser limits

可紊 提交于 2019-12-10 12:23:42
问题 In my app (sails 0.12.0) I want to extend a limit of bytes send upon POST request. So in my config/http.js I am uncommenting bodyParser and set it to: module.exports.http = { ... middleware: { ... bodyParser: (function () { var opts = {limit: 1024*1024*5}; // set it to 5 megabytes var fn; // Default to built-in bodyParser: fn = require('skipper'); return fn(opts); })() ... } ... } But now each my request seems to hang and in result I get 502 bad gateway in every request sent from browser. So: