Tag: sails.js

Sails'afterCreate(obj):对象不被更新

这篇文章有3个更新,可能会很长。 请参阅原文章节。 更新3 – 完整的Annonce代码 请注意,这是我目前的代码。 我已经更新了url()方法,并在afterCreate()内部注释了一切。 但代码仍然是一样的。 (对不起,这只是复制粘贴,所以评论用法语)。 /** * Annonce.js * * @description :: TODO: You might write a short summary of how this model works and what it represents here. * @docs :: http://sailsjs.org/#!documentation/models */ module.exports = { tableName: 'annonce', autoPK: true, attributes: { qte_commande: { type: 'integer', defaultsTo: 1, required: true […]

如何从现有模型创build新的Sails模型

我是Sails的新手,并创build一个简单的应用程序。 我现在坚持使用数据模型。 User模型如下: module.exports = { attributes: { firstName: { type: 'string' }, lastName: { type: 'string' }, email: { type: 'email', required: true }, password: { type: 'String' }, passwordSalt: { type: 'String' }, projects:{ collection: 'ProjectMember', via: 'userId' } } }; 我需要一个名为TinyUser模型,它从用户(如外键到用户)获取一些属性,以便我可以访问TinyUser而不是直接访问User 。 TinyUser模型如下: module.exports = { tableName: 'User', attributes: { firstName:{ type: […]

为生成和定义的sailsjs路由

我试图从我的服务中获得可用的API方法的完整列表。 这主要是显示我们通过所有控制器暴露的API调用。 我知道我可以反思sails.config.routes对象来获取定义的路由列表。 然而,似乎没有一种简单的方法来获取“自动”为您生成的蓝图路线列表。 现在一个想法是,我可以假设一个特定的模式与3种不同types的蓝图生成(行动,rest和快捷方式)。 对于这个简单的事实,这是一个糟糕的主意,这个框架还处于起步阶段,事情也可能发生变化。 我宁愿依靠一个方法来获取这个列表,根据什么是真正定义的,如果它确实改变了,那么我的代码应该自动反映。

Sails中的模型的独特属性

我是SAILS的新手。 我有以下型号。 型号\ Company.js module.exports = { attributes: { name: { type: 'string', required: true, unique: true }, description: { type: 'string', required: true } } }; 型号\ Project.js module.exports = { attributes: { name: { type: 'string', required: true }, key: { type: 'string', required: true, unique: true }, description: { type: 'string' }, […]

Promise:循环后执行

我想用水线ORM在循环中创build几个条目。 每个创build的对象被推入一个数组中。 所有对象创build完毕后,我需要返回完整的数组。 这是我的代码: share: function(req, res, next) { var params = {}, id = req.param('id'), img = {}, targets; if (!req.param('name')) { res.status(400); return res.json('Error.No.Name') } var promiseLoop = function(Tree) { // Function called after creating or finding Tree to attach to var array = []; if(!req.param('targets')) return Tree; // No targets provided => […]

如何将所有HTTP请求logging到我的Sails.js服务器?

如标题所示,如何将所有请求logging到我的Sails.js服务器? 有什么我需要改变我的日志configuration? 我只想查看发送到我的服务器的每个GET,POST等的列表。

节点主机configuration

我有一个有10个IP方向的VPS,我需要configuration一个Sails.js的安装,只能在一个IP方向上运行。 默认情况下,当我运行“帆升”项目它运行在所有的IP方向,我不想要它….我想在特定的IP中运行所有节点项目。 谢谢 :) root @ c352 [/ home / node / Shamman]#帆升降机 信息:启动应用程序… info:info:info:Sails.js <| info:v0.9.16 | \ info:/ |。\ info:/ || \ info:,'|' \ info:。-'.- == | / _–'info: –'——-' info: __—___–___—___–___—___–___ info: ____—___–___—___–___—___–___-__ info: info: Server lifted in / home / node / Shamman的信息:要查看您的应用程序,请访问localhost:1337 info:要closuresSails,请随时按+ C键。 debugging:———————————————— ——– debug::: Fri Dec 05 […]

如何使用Sails.js创build一个TCP服务器?

所以我使用Sails.js ,当我运行sails lift它正常服务的网站。 但是,如何创build一个TCP服务器,并在运行sails lift时运行,并不断监听来自客户端的原始TCP消息? 我已经find了Node.js这个简单的TCP服务器例子(这显然会适用于Sails): var net = require('net'); var server = net.createServer(function(socket) { socket.write('Echo server\r\n'); socket.pipe(socket); }); server.listen(1337, '127.0.0.1'); 我怎样才能把它融入Sails? 我是否需要修改app.js文件(这是我认为运行sails lift进入时运行)? 有任何想法吗?

如何在SailsJS应用程序中使用OrientDB

我是NodeJS和SailsJS的新手,之前正在使用Rails或PHP。 我想和OrientDB一起使用SailsJS。 什么是最好的方法? 到目前为止我发现了两个select,但是信息量还不是很大(还)。 与水线一起去,这是orientdb的适配器 深入一层,使用nodejs中的二进制适配器 任何帮助,提示,提示将不胜感激。 我有点失落,但非常激动,要更多地了解这些伟大的工具。 谢谢!

当部署在heroku上时,Sails js连接恢复到开发

我一直在尝试在heroku上使用mongolab作为我的mongodb来部署我的sails应用程序。 我使用了以下连接,一个用于开发,一个用于生产: local_mongo : { adapter : 'sails-mongo', host : 'localhost', port : 27017, database : "something" }, heroku_mongolab : { adapter : "sails-mongo", url : "mongodb://*****:******!@ds063160.mongolab.com:63160/something" } 我也设置我的local.js文件使用开发环境,并在gitignore上的文件。 最后在我的development.js上做以下工作 module.exports = { models: { connection: 'local_mongo' } }; 在我的production.js module.exports = { /*************************************************************************** * Set the default database connection for models in the production […]