sails.js

How does the SANE stack represent parent/child relationships on a single model

别等时光非礼了梦想. 提交于 2020-01-05 11:37:54
问题 How do I represent a parent/child relationship on the same model? An example of this is a model representing a folder. A parent folder can have many children folders. But a child folder can only have one parent folder. Ember.js has the concept of reflexive relations. I would like to implement the first option. "... explicitly define the other side, and set the explicit inverse accordingly ..." How would I go about setting that up on the sails.js side of the SANE stack? 回答1: I'm not sure what

Sails min, max, minLength, maxLength for number and string types gives userError

可紊 提交于 2020-01-05 09:28:00
问题 I am using waterline v0.13.5 package with expressjs. I get an user error { userError: The attribute 'str' on the 'action' model contains invalid properties. The property 'minLength' isn't a recognized property. when trying to use min, max (with number type) and minLength, maxLength (with string type). This same type of error is also received with isIn property when used like this "isIn": [1,2,3] . autoPK: true also doesnt work as expected. It forces me to define _id in the model attributes

sails.js less livereload with grunt watch not working

不问归期 提交于 2020-01-05 09:07:08
问题 I got my less files compiled in css perfectly by grunt and I see result in .tmp/public/styles So now livereload with grunt-contrib-watch should be made naturally in sails generated project ? Or do I have to make a special configuration ? I found that in tasks/pipeline.js file but not sure of what to do. // CSS files to inject in order // // (if you're using LESS with the built-in default config, you'll want // to change `assets/styles/importer.less` instead.) var cssFilesToInject = [ 'styles/

emit socket.io and sailsjs (Twitter API)

巧了我就是萌 提交于 2020-01-05 05:40:27
问题 I got the twits, I'm printing all of them ok in console, but I would like send the data to the view and I don't know how can I do it using socketio. any idea? var TwitterController = { 'index': function(req,res) { var twitter = require('ntwitter'); var twit = new twitter({ consumer_key: '...', consumer_secret: '...', access_token_key: '...', access_token_secret: '...' }); twit.stream('statuses/filter', { track: ['dublin', 'spain']} , function(stream) { stream.on('data', function (data) {

Sails.js send data from partial controller to partial view

别等时光非礼了梦想. 提交于 2020-01-05 03:28:50
问题 I am new in sails.js. I have worked on opencart. In sails.js, How can we reuse functionality like dynamic categories (based on the tables data). So in this case there will be a menu controller and menu.ejs view. What i need is there will be a parent controller and a parent view like HomeController.js and HomeView.ejs . Inside that menu part will be reuse. same like header controller/view , footer controller/view . So if i route to '/home' then it will call HomeController.js. Then home will

How to generate map files for CSS in a sails app?

痴心易碎 提交于 2020-01-05 03:26:32
问题 Hi have a sails project with bootstrap included in bower.json: ... "dependencies": { ... "bootstrap": "~3.2.0" ... } All the css, fonts and js are copied correctly but the map file is not copied to the assets/vendor/bootstrap directory nor the .tmp dir. I can't figure out what process copies the filed from bower_components/bootstrap/dist/css where the bootstrap.css.map file does exists. There must be something from tasks/config/bower.js but I am a bit puzzled on how bower know which files to

Sails.js Can't set headers after they are sent

故事扮演 提交于 2020-01-05 00:52:30
问题 I am using sailsjs v0.10.5. I am trying to redirect to login after verifying user email and update the database before redirect. I am using redirection in my update callback. But it sending the error after updating the database 'Cant send headers after they are sent'. The following is the code am using for redirection: verifyEmail: function(req, res){ var userId = req.param('userId'); User.update({id: userId},{isVerified: true}).exec(function(err, user) { if (!err) { req.flash('error', 'Your

Sails js subscribe to model changes scoped by groupid attribute

荒凉一梦 提交于 2020-01-04 12:45:34
问题 I have a model named Groupfeed which looks like this module.exports = { schema:true, attributes: { groupid: { model:'groups', required:true }, postid: { model:'post', required:true }, objectid: { model:'objects', required:true }, } }; On the client side I can subscribe to the Groupfeed model using io.socket.get('/groupfeed') which is done automatically by the blueprint api and then io.socket.on('groupfeed',function(obj){console.log(obj)}) would give me updates on the model changes when I

Dynamically define and get Models in Waterline

て烟熏妆下的殇ゞ 提交于 2020-01-03 01:58:11
问题 I was wondering if it's possible in Waterline to define models or get a model by name like in Node-ORM2. Defining: var Person = db.define("person", { name : String, surname : String, age : Number, // FLOAT male : Boolean, continent : [ "Europe", "America", "Asia", "Africa", "Australia", "Antartica" ], // ENUM type photo : Buffer, // BLOB/BINARY data : Object // JSON encoded }, { methods: { fullName: function () { return this.name + ' ' + this.surname; } }, validations: { age: orm.enforce

sails.js Getting a POST payload with text/plain content type

♀尐吖头ヾ 提交于 2020-01-02 16:06:07
问题 I'm developing a sails.js (node.js framework based on express) aplication, which is going great but ]I can't solve this detail... I need to send POST requests cross domain from internet explorer 8 and 9. For that I'm forced to use xDomainRequest object, wich doesn't allow to set a Content type header. So, when the request gets to the server the content type is "text/plain", which doesn't fire the bodyParser express middleware, so my req.body is an empty object and I can't see the payload I'm