Giter Club home page Giter Club logo

mongodbutils's Introduction

MongoDBUtils

MongoDB access and operate tools, suport use sql statement to ope mongodb (select, update, insert, delete)

普通构造
MongoDbOperater ope = new MongoDbOperater();
ope.setMongoClient(client);
spring 构造
<bean id="mongoClient" class="com.mongodb.MongoClient"\>
...
<\bean>
<bean id="ope" class="org.shenjitang.mongodbutils.MongoDbOperater">


特性:

1,支持sql语法的增删改查

2,支持原生mongodb操作

3,自动转换bean

4,支持GridFS操作

使用(假设数据库名为 db1): String sql = "select * from colName where name='tom' and age>15 and score between (80, 100) and city in ("shanghai", "beijing", "guangzhou");
Persion persion = ope.findOneObj("db1", sql, Persion.class);
List persionList = ope.findAllObj("db1", sql, Persion.class);
... 支持的sql样例:
sql = "select * from table1 where name='aaa' and age>=18 and foot in (1,2,3) and abc in ('a1','a2','a3') order by age,name limit 123";
sql = "select * from algoflow_instance_log where functionName='f1' and reuseResult=false and returnCode=0 and action='LEAVE' order by timestamp desc limit 100";

更新:
sql = "update table1 set a=1, b='sdaf', c='2012-11-23 17:45:32' where name='aaa' and age>=18 and foot in (1,2,3) and abc in ('a1','a2','a3')";,
ope.update("db1", sql);
sql = "delete from table1 where name='aaa' and age>=18 and foot in (1,2,3) and abc in ('a1','a2','a3') order by age,name limit 123";
ope.remove("db1", sql);
以上sql都可以执行:QueryInfo uinfo = ope.sql2QueryInfo("db1", sql);

mongodbutils's People

Contributors

xiaolie avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.