Tag: 水线

如何使用“find哪里”SailsJS蓝图路线?

用例 我想创build一个复杂的查询,使用SailsJS“ Find Where ”蓝图路线,使用多个标准 。 但是,我无法使用等于比较器和条件成功。 我找不到有关如何实现Find Where路由的足够的文档,所以我通过源代码工作并提出了以下scheme。 题 使用SailsJS Find蓝图路线,如何实现: 平等比较 和条件 成功案例 以下情况将返回相应的响应: http://localhost:1337/api/user?name=fred http://localhost:1337/api/user?where={"name":{"startsWith":"fred"}} http://localhost:1337/api/user?where={"name":{"endsWith":"fred"}} http://localhost:1337/api/user?where={"name":{"contains":"fred"}} http://localhost:1337/api/user?where={"name":{"like":"fred"}} http://localhost:1337/api/user?where={"or":[{"name":{"startsWith":"fred"}}]} http://localhost:1337/api/user?where={"or":[{"name":{"startsWith":"fred"}},{"path":{"endsWith":"fred"}}]} 失败场景 以下情况会返回一个空的响应: http://localhost:1337/api/user?where={"name":{"equals":"fred"}} http://localhost:1337/api/user?where={"name":{"=":"fred"}} http://localhost:1337/api/user?where={"name":{"equal":"fred"}} http://localhost:1337/api/user?where={"and":[{"name":{"startsWith":"fred"}}]} http://localhost:1337/api/user?where={"and":[{"name":{"startsWith":"fred"}},{"path":{"endsWith":"fred"}}]}

Sails.js中的密码确认和外部模型validation

也许有一天我一直在玩Sails。 我试图围绕在Sails.js中进行大量validation的最佳方式进行讨论。 这是情景: Registration Form: Username: _______________ E-Mail: _______________ Password: _______________ Confirm: _______________ 用户input: 一个正确的电子邮件 一个已经存在的用户名 两个密码不匹配 期望的结果: Username: _______________ x Already taken E-Mail: _______________ ✓ Password: _______________ ✓ Confirm: _______________ x Does not match 要求,几个要点: 用户input的每一个方面都会收到所有的错误信息 (不仅仅是第一个)。 他们不是模糊的 (“用户名已被占用”或“用户名必须至less有4个字母”比“无效的用户名”更好) 内置的模型validation显然不会负责检查匹配的密码确认(SRP) 我认为我需要做的是: UserController的: create: function(req, res) { try { // use a UserManager-Service to keep […]

没有http端点的Sails.js工作者节点

我正在构build一个使用RabbitMQ的sails应用程序,将Web请求中的一些任务委托给工作节点。 这几乎是https://devcenter.heroku.com/articles/background-jobs-queueing和https://github.com/heroku-examples/node-articles-nlp中描述的模式。 虽然我可以在worker节点中执行sails.lift(),但是似乎跳过http端点(express)和一些grunt任务(bower / frontend dependencies download,less,web资源复制到.tmp, …)。 有什么办法可以实现吗? 谢谢! 编辑 我需要在我的工作人员的帆,所以我可以使用水线ORM和定义和暴露在帆中的共同服务。

使用Sails.js进行全文search

Sails.js和/或Waterline是否可以进行全文search? 我知道PostgreSQL支持全文search,但看起来像Waterline的PostgreSQL适配器支持这个function,据我所知。 Waterline的contains辅助方法是否可以进行高效的全文search?

Sails.js相同模型多对多协会

Sails.js .10 rc8 我完全没有想到这个 我有一个名为User的模型,我想将它集合到其他用户(如朋友列表)中。 像一个多对多的关联 //User.js friends: { collection: 'user', via: 'friends' } 但是当我运行.populate('friends')它不填充任何东西。 有任何想法吗?

风帆js和Sequelize

我正在学习Node.js和Sails是我的select框架。 我想在MySql数据库的项目中使用它,我认为Sequelize Orm更完整。 我怎样才能使用Sequelize Orm in Sails而不是Waterline? 谢谢

将表更改迁移到生产sailsjs表的最佳方法

我刚刚从数据库中丢失了11000条logging,只是运行sailsjs的命令,而没有包含–prod部分,所以我想我应该问在Model.js被更改时更改生产服务器上的表的最佳方式是什么? 谢谢

我如何处理帆中独特的领域?

我已经在我的模型中定义了一个独特的字段,但是当我试图testing它似乎不被Error (E_UNKNOWN) :: Encountered an unexpected error: MongoError: E11000 duplicate key error index:检查,因为我得到一个Error (E_UNKNOWN) :: Encountered an unexpected error: MongoError: E11000 duplicate key error index:而不是validation错误。 处理风帆独特领域的最佳方法是什么? // model/User.js module.exports{ attributes: { email: {required: true, unique: true, type: 'email' }, …. } // in my controller User.create({email: 'hello@gmail.com'}).then(…).fail(….) User.create({email: 'hello@gmail.com'}).then(…).fail(// throws the mongo error ) // […]

sails.js + waterline一对多模型关联,删除Many时应该发生什么?

我和老师(一)和孩子(老师)之间有一对多的关系。 如果我做: Teacher.destroy(teacherId).exec(function(err){}); 孩子们不会自动移除。 这是一个错误,或者我应该手动删除它们? 如果这不是一个错误,不删除孩子的解释是什么?

帆postgresql多对多协会不工作

我试图在两个模型,运营商和组之间build立多对多的关联。 两个模型是: -Operator.js var Operator = { connection:'postgresql', tableName: 'operator', schema:true, attributes: { firstName: { type: 'string', required: true, max: 64, columnName: 'first_name' }, lastName: { type: 'string', required: true, max: 64, columnName: 'last_name' }, birthDate: { type: 'date', columnName: 'birth_date' }, sex: { type: 'string', enum: ['M', 'F', 'NA'], columnName: 'sex' }, email: { […]