【发布时间】:2014-09-09 08:17:48
【问题描述】:
我需要使用 INTEGER COLUMN 进行类似查询的 mongoid 搜索。例如:
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
我已经尝试过以下示例。但没有运气:(
User.where(:$where => "/^#{params[:mobile]}/")
User.any_of({mobile: /.*#{params[:mobile]}.*/i})
User.where(mobile: /8801/))
用mongoid怎么写?
【问题讨论】:
-
手机?您是否将电话号码存储为号码?
标签: ruby-on-rails mongodb mongoid mongoid4