Mongoid:查询一系列 ASCII 字符
我在基于 Mongoid 的类中有一个带有名为 named
的字符串字段的集合。我希望能够查询 name
字段中以 a 到 f 中的字母开头的所有文档,不区分大小写。通过 Mongoid 执行此操作的最佳方法是什么?我假设该接口与 ActiveRecord 类似,因此如果可以在 ActiveRecord 中完成,那么也可以通过 Mongoid 完成。
I have a collection with a string field called named
in my Mongoid based class. I'd like to be able to query for all documents that begin with the letters in the a through f in the name
field, case insensitive. What's the best way to do this through Mongoid? I'm assuming the interface is similar to ActiveRecord, so if it can be done in ActiveRecord, it can probably be done through Mongoid as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可以解决问题
i - 不区分大小写
This will do the trick
i - for case insensitive