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很优雅啊,哈哈.
时间: 2024-10-13 02:01:53