Tag: sails.js

哪一个使用asynchronous或callback

我正在使用sailsjs框架在nodejs中开发一个简单的应用程序。 我的任务是创build一个API端点,我必须从数据库validation传入的参数是否有效。 如果input参数无效,那么如果input参数有效,我会返回JSON格式的错误,然后我需要做一些计算,然后保存到数据库,然后发送一个邮件,并以JSON格式给出成功响应。 混乱是如果我使用asynchronous如何强制asynchronous不input参数无效时调用下一个函数。

使用Sails.js水线在多个模型中进行高效的查询

我正试图find一种有效的方法来检索分布在多个模型上的结果。 在我的例子中,我有三种模式: 存储video数据的Video ,包括video的创build者 存储用户数据的用户 存储哪个用户跟随哪个其他用户的跟随Follower 我的模型的简化版本如下所示: // Video.js module.exports = { attributes: { title: { type: 'string' }, creator: { model: 'User' } } }; // User.js module.exports = { attributes: { user_name: { type: 'string' } } }; // Follower.js module.exports = { attributes: { user: { model: 'User' }, follower: { model: […]

无法连接MySQL与Sails js

我正在使用sails最新版本(0.10。*),我试图连接mysql数据库,但是抛出下面的错误。 info:启动应用程序…错误:挂钩( orm )加载失败! 错误:错误(E_UNKNOWN)::遇到意外的错误:查询时查询不活动超时。 在Query的emitNone(events.js:67:13)处执行/(home / pavan / pavanwork / development / plotstoday / node_modules / sails-> mysql / node_modules / mysql / lib / protocol / Protocol.js:154:17)。 Query._onTimeout>(/ home / pavan / pavanwork / development / plotstoday / node_modules / sails-> mysql / node_modules / mysql / lib / protocol / sequences / […]

Sails.js + ES6:什么是最好的架构?

我刚刚从节点 0.12升级到节点 4.0。 我正在使用sails.js来构build我的应用程序。 有了节点的新的ES6支持和sails.js ,我有点困惑,我的文件夹结构将如何看起来像? 我是否仍然继续在controllers使用我的ORM或将它们移动到单独的图层? 有人可以build议一个好的项目,我可以参考,以ES6和风帆清洁架构?

帆 – 反应:从父组件访问道具

我正在开发一个使用Sails和React的Web应用程序。 我试图从我的数据库中获取所有的用户。 所以,为了让所有的用户,我写了下面的代码 启动UserController index : function(req,res){ User.find() .then(function(users){ renderTo(routes, req.wantsJSON, res, "/user" , {title: 'Users'}, {'users' : users}); }).catch(function(err){ return res.negotiate(err); }); } 现在,要接收用户数组,我的React代码是: 反应代码 var React = require('react'); var http = require('http'); var UserList = require('./userList'); var user = React.createClass({ render: function() { return ( <UserList {…this.props} /> ); } }); module.exports = […]

javascript无效的正则expression式:无与伦比的')'

我刚刚在我的项目上添加了一个pipe理面板钩子。 当我尝试提起帆时遇到了这个错误: warn: Sails' built-in layout support only works with the `ejs`, `handlebars`, `ractive` view engines. warn: You're using `jade`. warn: Ignoring `sails.config.views.layout`… 和这个错误: SyntaxError: Invalid regular expression: /^\admin\(.*)\/?$/: Unmatched ')' config / view.js引擎设置为jade,布局为false。

SailsJs错误。 TypeError:无法读取未定义的属性'属性'

我正在使用sailsjs和mongodb。 我得到错误“TypeError:无法读取属性'未定义的属性”。 这是模型: UserInterest.js module.exports = { attributes: { id: { type: 'integer', primaryKey: true }, name: { type: 'string' }, profiles: { collection: 'UserProfile', via: 'interests'} } }; UserProfile.js module.exports = { attributes : { id : { type : 'string', autoIncrement : true, primaryKey : true }, createdAt : { type : 'datetime' […]

Sailsjs Model.update不能在控制器中工作

只是一个快速的初学者问题… 控制器是否允许在Sails中执行更新? 我知道行动路线,但是我不能得到这样的代码来更新。 //controller code (this DOES NOT update) Packets.update({packet:5},{cron:'locationhistory'}) .then( function(r){ console.log(r); }); 这个过程起作用,所以我很困惑,为什么上面不会。 //controller code that does work, however I'm calling a custom function sails.models.packets.updateMyPacket('locationhistory', 9, function( response ){ console.log(response); }); // model code updateMyPacket: function( p, num, cb) { Packets.update({ cron: p}, {packet: num}).then( function( packets){ cb(packets); }); } 任何人都可以帮忙吗? 我错过了什么? 谢谢Matt

Sails.JS – 重试NTLMvalidation失败?

我目前正在编写一个基于Sails.JS的NodeJS应用程序,而我正在使用ntlm-express进行NTLM身份validation。 当authentication成功时,这种方式非常好,但是在失败的情况下(例如,Firefox用户input错误凭证)ntlm-express返回500错误代码,FireFox将凭据存储在caching中,用户无法login到Web应用程序,因为他没有得到一个新的提示input凭据。 用户login的唯一方法是手动清除FireFox中的authenticationcaching,然后重试。 我想要做的是在ntlm-express无法validation用户的情况下,再次提示他input凭证而不是返回500。 有没有人做过这样的事情,并指出我正确的方向? 我在网上发现了关于这个主题的很less的信息…

Sails.js资产交付到http

我是新来的风帆和节点,我有一个关于如何通过ejs标签<% – %>或<%=%>通过网页上的控制器交付模型的问题。 所以,我有他们的控制器Model1,Model2和Model1Controller,Model2Controller 2模型。 我想在Model2Controller的show / findall动作中显示Model1属性(假设名称Model1.name)。