您的位置:首页 > 运维架构 > Shell

Query in Java as in Mongo shell 【Jongo】

2016-03-01 20:25 567 查看

what ?

在 java 中直接使用 shell 操作 mongodb

how ?

DB db = new MongoClient().getDB("dbname");

Jongo jongo = new Jongo(db);
MongoCollection friends = jongo.getCollection("friends");

MongoCursor<Friend> all = friends.find("{name: 'Joe'}").as(Friend.class);
Friend one = friends.findOne("{name: 'Joe'}").as(Friend.class);


why ?

最直接的作用是可以简化代码量

在 java 中使用 shell 操作很灵活方便

性能更好

other

官方

http://jongo.org/

github

https://github.com/bguerout/jongo
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: