mongoid模糊查询

 

How to use the like query with Mongoid . Basically I wanted something like the familiar SQL query:

SELECT * FROM Apps WHERE name LIKE ‘%aaa%’

 

I couldn’t find anything similar in the Mongoid documentation, but according to the MongoDB documentation you can do regex searches.

Apps.where(name: /aaa/)

Package.where(title: /博影/).first title
= "博影" Package.where(title: /#{title}/)

注意这行语句在vim里会被误导,vim会把#以后的当作注释,忽略这一点啊.不影响执行效果

现在觉得mongoid很优雅啊,哈哈.

posted @ 2014-06-25 11:00  冰凌花花~  阅读(448)  评论(0编辑  收藏  举报