当前位置: 首页 > 工具软件 > Mongoid > 使用案例 >

mongoid模糊查询

戚森
2023-12-01

 

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

转载于:https://www.cnblogs.com/iwangzheng/p/3807629.html

 类似资料: