您的位置:首页 > 数据库 > Mongodb

mongoDB知识汇总

2015-08-11 16:11 519 查看
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}})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: