当前位置:Gxlcms > 数据库问题 > mongoDB知识汇总

mongoDB知识汇总

时间:2021-07-01 10:21:17 帮助过:2人阅读

= new MongoClient ("hostname", 27017);

DB db = mongo.getDB("dataqueuenode");

DBCollection collection = db.getCollection("entity");

  • MongoDB CRUD in java

BasicDBObject query = new BasicDBObject();

    query.put("type" , "S2F");

    query.put("subtype" , "SQL Orders");

    query.put("state" , "disputed");

Query Document

    collection.findone(DBObject o);   // search one specific record

    collection.find(DBObject o);         //search all specific records

Remove Document

     collection.remove(DBObject o);    // remove specific records

Insert Document

       collection.insert(DBObject arr);       // insert record

Modify Document

       collection.update(DBObject q , DBObject o );       //update record

       * @param q      the selection criteria for the update

       * @param o      the modifications to apply

  • MongoDB command

技术分享

Reference
doc: http://docs.mongodb.org/manual/core/crud-introduction

  • One Shell for MongoDB

        MongoVUE

 

MongoDB中条件操作符有:

  • (>) 大于 - $gt
  • (<) 小于 - $lt
  • (>=) 大于等于 - $gte
  • (<= ) 小于等于 - $lte
>db.testtable.find({age : {$gt : 22}})

 

mongoDB知识汇总

标签:

人气教程排行