You should have installed and started MongoDB server, if you didn't yet, go to MongoDB.
I suggest using pip install command , like this:
The find is the way you query data in MongoDB. Its similar to "select" statement in SQL query language.
Lets prepare the database for our demonstration.
In windows, the mongod server process run in a cmd window, when you opens a lot of windows, the switch becomes a problem. Its very nice to run the server as a service, so it run in background and you can make it start when Windows power up if you have a local web application based on MongoDB.
By default, if you don't use sort, the returned results always ordered by the order they inserted.
It is also true for MySQL.
In relational database, sometimes we need to construct sql string dynamically when the query is complex. For example , search an array of keywords, or query a range of values.
Or construct a range query
The common select count(*) syntax in relational SQL is very handy to get the number of records not the records itself. How to to this in MongoDB?
If all you want is get the total number of items matching the query, use the count() function.
MongoDB support both of the two flavor of replication. Replica set is the improved version of master slave replication, it support automatic fail over. When the primary goes down, one of the slaves will automatically be promoted to primary. In a MongoDB replica set, there is a arbiter server responsible for observing the failure and automatically elect a new .