首页 > 其他 > 详细

mongoid模糊查询

时间:2014-06-26 23:58:54      阅读:610      评论:0      收藏:0      [点我收藏+]

 

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很优雅啊,哈哈.

mongoid模糊查询,布布扣,bubuko.com

mongoid模糊查询

原文:http://www.cnblogs.com/iwangzheng/p/3807629.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!