正则表达式 – Morphia mongoDB通配符查询

栏目: 数据库 · 发布时间: 6年前

内容简介:翻译自:https://stackoverflow.com/questions/12371299/morphia-mongodb-wildcard-query

直截了当的问题,是否有人知道如何使用链接到 mongoDB 数据库的morphia进行通配符查询?

这就是mongo语句的样子:

Mongo:db.users.find({name:/ Joe /})

SQL:SELECT * FROM users WHERE name LIKE“%Joe%”

我的morphia语句如下:

Morphia:ds.find(File.class,“filename”,“/ test /”).order(“filename”).asList();

我的数据库中有文件名,例如test1,test等

如果有人可以请告诉我,如果甚至可以使用吗啡,我将非常感激.

谢谢

你所谓的“通配符”实际上是“ Regular Expression ”.

表示正则表达式的 Java 类是 Pattern .您可以将它们传递给Morphia的Query对象的过滤器方法.

// create a regular expression which matches any string which includes "test"
Pattern regexp = Pattern.compile("test");
// use this regular expression to create a query
Query q = ds.createQuery(File.class).filter("filename", regexp).sort("filename");

翻译自:https://stackoverflow.com/questions/12371299/morphia-mongodb-wildcard-query


以上所述就是小编给大家介绍的《正则表达式 – Morphia mongoDB通配符查询》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Programming Python

Programming Python

Mark Lutz / O'Reilly Media / 2006-8-30 / USD 59.99

Already the industry standard for Python users, "Programming Python" from O'Reilly just got even better. This third edition has been updated to reflect current best practices and the abundance of chan......一起来看看 《Programming Python》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具