我需要使用 INTEGER COLUMN 进行类似查询的蒙古式搜索.例如:
I need a mongoid search like query with INTEGER COLUMN. For example:
SELECT * FROM users WHERE mobile LIKE '%9980%';这是我的模特:
class User include Mongoid::Document include Mongoid::Timestamps ## # Columns field :name, type: String field :mobile, type: Integer end我已经尝试了以下示例.但没有运气:(
I already tried following examples. But no luck :(
User.where(:$where => "/^#{params[:mobile]}/") User.any_of({mobile: /.*#{params[:mobile]}.*/i}) User.where(mobile: /8801/))如何用蒙古语写出来?
推荐答案尝试一下
User.where(mobile: /.*#{params[:mobile]}.*/i)