Greater than: $ GT
Greater than or equal to: $ GTE
Less than: $ lt
Less than or equal to: $ LTE
Not equal to: $ ne
In: $ in
Example 1: query the persons whose age is greater than 20 and
DB. XXX. Find ({"Age": {"$ gt": 20, "LTE": 30 }});
MongoDB documentation is similar to JSON format
JSON data type:
JSON contains six data types, including null, Boolean, number, String, array, and object. there is no date type in JSON, and there is only one numeric type. There is no way to
Reprinted from http://www.cnblogs.com/spnt/
The sharding maintenance of MongoDB is also about the several commands, which are relatively simple. We will use the example for demonstration.
1. List all shard servers
Note that you need to
Query records
Common Query
> Var cursor = dB. Things. Find ();
> While (cursor. hasnext () printjson (cursor. Next ());The above example shows the cursor-style iterative output. The hasnext () function tells us whether there is any data. If so, you
Brief Introduction
Capped collections is a set of excellent performance with a fixed size (Set of capacity), with LRU (least recently used) Rules and Insertion Sequence for age-out (aging removal) processing: automatically maintains the insertion
Recently, the San Francisco-based Stripe Company released mosql, which allows you to easily generate reports from MongoDB using a replicated PostgreSQL database. Mosql is based on mongoriver, which is also a product of stripe. It can monitor MongoDB
Primary learning of MongoDB master-slave Synchronization
MongoDB master-slave Synchronization
MongoDB master-slave synchronization is very simple. Host startup declares that you are the host. when starting the slave, you only need to declare that
Document directory
1. Preparation Information Processing (each node can be the same or different)
2. Start the mongod instance
3. Configure and initialize the replica set
4. view the replica set status
1. read/write splitting
2. automatic
Create document
Insert data into MongoDB using insert,
Example: DB. refactor. insert ({"refactor's blog": "http://www.cnblogs.com/refactor "})
This operation adds a "_ id" Key to the document and stores it in the database.
Batch insert
If you want
I have been very interested in the principles and practices of distributed systems for a long time, and I have been very curious about MongoDB. I have finally had time to experiment with it!
I set up a replica sets + sharding test cluster
1. Download suitable mongodb
Official Website: http://www.mongodb.org/downloads
MongoDB for Windows has three versions:
MongoDB for Windows Server 2008 R2 only runs on Windows Server 2008 R2, Windows 7 64-bit, and updated Windows versions. This
MongoDB is a database server: it runs on the frontend or backend and waits for the user's connection. When you start MongoDB, the following results are displayed:
~/$ ./mongod
## some logging output
#
Tue Mar 9 11:15:43 waiting for connections on
Here we will not describe what MongoDB is. It mainly solves the problem of storing large data volumes. You can search for the keyword "MongoDB.
Windows version:
1, download: http://www.mongodb.org/downloads
2, download the latest stable
Mongodb DBObject supports saving multi-dimensional arrays. When adding elements, use the "$ push" operator and "$ pull" When deleting elements ".
However, the problem arises when updating. mongodb first supports "$" to locate an element in the array,
Object IDs
Documents in mongodb must be identified by a unique keyword _ id.
_ Id field
Almost every mongodb document uses the _ id field as the first attribute (with some exceptions in the system set and Capacity Set (capped collection ). The _ id
Create an index in the background
By default, index creation will block other database operations. V1.3.2 and later provide the background index creation function.
Delete Index
Delete all indexes of a specified
Mongodb provides an interesting "Multi-key" feature that automatically indexes the array values of objects. Tags are a good example. Suppose you have an article that contains many classification tags:
$ dbshell> db.articles.save( { name: "Warm
MongoDB supports two-dimensional geographic information indexing. It is designed for location-based queries in the mind, such as "finding N places closest to my location ". It can also efficiently process additional query conditions, such as
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service