问题标签 [meta-where]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
731 浏览

ruby-on-rails - ruby on rails 3 - 使用 gem 进行高级搜索

我有一个用户模型,其中包含本地、Skype 和电话(布尔值,“t”或“f”)和性别(字符串,“男”或“女”)的列。每个用户可以在关联的 SkillMap 模型中拥有许多技能,该模型具有 Skill_id 和方向(字符串,“Teach”或“learn”)

我一直在搞乱 MetaWhere、Squeel 和 RanSack,试图找出哪一个可以让我以最好的、最易读的和最像 rails 的方式搜索这些用户。谁能给我指出最合适的宝石,或者给我一些关于如何构建它的提示?

目前,每次执行搜索时,都会在搜索表中创建一个像下面这样的对象(抱歉格式不好,我不知道如何保存没有这些破折号的数组)

因此,在这种情况下,我想找到任何使用 Skype 或本地标志为真的用户(忽略电话 = 'f'),谁的性别标志是“男性”,并且谁有一个相关的技能地图,其中方向 = '教'和技能 ID = 795,并且谁有一个技能图,其中方向 = '学习' 并且技能 ID 在 (789,771,827)

我可以尝试编写 SQL,如果这会使它更清晰,但我只知道如何使用糟糕的子查询来完成它(DBA 可能想跳过这部分)

如果这些字段中的任何一个为空白或错误​​,我不想将它们作为搜索条件包含在内。

无论如何,这是我的问题。感谢您的关注!

干杯,约拿

0 投票
1 回答
132 浏览

ruby-on-rails - Proper syntax and use cases for MetaWhere in_all and in_any

I've been exploring the capabilities of MetaWhere over the last couple of days. Most of the predications are pretty straightforward, but I'm stuck on how to use in_all and in_any.

Here are some of my attempts:

I'm assuming they're supposed to AND or OR a bunch of IN clauses, but I can't figure out how to set them up properly, nor have I been able to find any decent documentation. And if anyone has any examples of situations where these predications would be useful, that would be appreciated as well.

0 投票
1 回答
77 浏览

ruby-on-rails - 来自查询的 Metawhere 抽象条件

我正在使用 Metawhere rails gem 来查询我的数据库。我有一个有效的查询:

现在我试图从这样的查询中抽象出条件:

但第一行给了我:语法错误,意外的 tASSOC,期待 ']

我尝试了很多事情,比如在查询中将条件设为字符串和 eval(conditions)。但这给了我 SyntaxError: (eval):1:in `irb_binding': compile error (eval):1: syntax error, unexpected ',', expecting $end

我被困住了。如果你能帮助我,那将不胜感激。

罗格

0 投票
1 回答
87 浏览

ruby-on-rails - 使用 meta_where gem 的 meta_search

我正在使用 meta_search 和 meta_where gem。在我的控制器文件中:

当我运行此代码时,我在浏览器中出现这样的错误