码迷,mamicode.com
首页 > 数据库 > 详细

mongoDB知识汇总

时间:2015-08-11 18:30:54      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

Agenda

  • Traits
Agility,Scalability,high-performance
Free and open-source
NoSQL database
JSON-like
Document-oriented database(schema flexible)
  • Document Database
A record in MongoDB is a document, which is a data structure composed of field and value pairs. MongoDB are similar to JSON objects.
技术分享
  • SQL to MongoDB Mapping Chart
The following table presents the various SQL terminology and concepts and the corresponding MongoDB terminology and concepts.
技术分享
  • Connect to MongoDB
MongoDB default port is 27017, and default local host is 127.0.0.1

MongoClient mongo

= 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知识汇总

标签:

原文地址:http://www.cnblogs.com/huaxiong/p/4721317.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!