内容简介:翻译自: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等
如果有人可以请告诉我,如果甚至可以使用吗啡,我将非常感激.
谢谢
表示正则表达式的 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通配符查询》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Nature of Code
Daniel Shiffman / The Nature of Code / 2012-12-13 / GBP 19.95
How can we capture the unpredictable evolutionary and emergent properties of nature in software? How can understanding the mathematical principles behind our physical world help us to create digital w......一起来看看 《The Nature of Code》 这本书的介绍吧!