1. Perform Mongod.exe server startup database and log that can be followed by parameter description.
eg
Mongod.exe--bind_ip 127.0.0.1--logpath "F:\data\dbConf\mongodb.log"--logappend--dbpath "F:\data\db"--port 19901-- ServiceName "MONGODB1"--servicedisplayname "Mongodball"--install
2. Perform Mongo.exe Client connection
View all databases: Show DBS
Syntax format for creating a database: Use database_name
Delete Current database: Db.dropdatabase ()
Switch to database: use database_name
Delete collection: Db.collection.drop ()
MongoDB uses the Insert () or Save () method to insert a document into the collection:
Db. Collection_name.insert (document)
MongoDB uses the update () and Save () methods to update the documents in the collection:
The update () method is used to update a document that already exists. The syntax format is as follows:
Db.collection.update (
<query>,//query:update the query condition, similar to the SQL update query inside the where.
<update>,//update:update objects and some updated operators (such as $, $inc ... ) can also be understood as the SQL update query within the set after the
{
Upsert: <boolean>,//upsert: Optional, this parameter means that if there is no record of update, insert objnew,true as INSERT, default is False, do not insert.
Multi: <boolean>,//multi: Optional, mongodb default is False, only update the first record found, if this parameter is true, the condition is checked out all the records are updated.
writeconcern: <document>//writeconcern: Optional, throws an exception level.
}
)
The Save () method replaces an existing document with an incoming document. The syntax format is as follows:
Db.collection.save (
<document>,
{
Writeconcern: <document>
}
)
Db.col.update ({' title ': ' MongoDB Tutorial '},{$set: {' title ': ' MongoDB '}})
MongoDB Delete Document
Parameter description:
Document: Documentation data.
Writeconcern: Optional, throws an exception level.
The basic syntax format for the Remove () method is as follows:
Db.collection.remove (
<query>,
<justOne>
)
Remove all data: Db.col.remove ({})
The syntax format for MongoDB query data is as follows:
Db. Collection_name.find ()
Read data in an easy-to-read manner
Db.col.find (). Pretty ()
Action format example of a similar statement in an RDBMS
equals {<key>:<value>}Db.col.find ({"By": "Rookie Tutorial"}). Pretty ()where by = ' Rookie Tutorial '
Less than {<key>:{$lt: <value>}} db.col.find ({"likes": {$lt:)}. Pretty () Where likes < 50
Less than or equal to {<key>:{$lte: <value>}} db.col.find ({"likes": {$lte:]}). Pretty ( ) where likes <= 50
Greater than {<key>:{$gt: <value>}} db.col.find ({"likes": {$gt:}}). Pretty ()where Likes > 50
Greater than or equal to {<key>:{$gte: <value>}} db.col.find ({"likes": {$gte:]}). Pretty ( ) where likes >= 50
Not equal to {<key>:{$ne: <value>}} db.col.find ({"likes": {$ne:}}). Pretty ()where Likes! = 50
The condition operators in MongoDB are:
(>) Greater than-$GT
(<) less than-$lt
(>=) greater than or equal to-$gte
(<=) less than or equal to-$lte
Db.col.find ({"likes": {$gt: 100}})
Similar to the SQL statement:
Select * from Col where likes > 100;
The above is I watch the site on the side of the record down.
This article is from "Walking Taihang Yan Zhao" blog, please be sure to keep this source http://chaoslee.blog.51cto.com/10643967/1856759
MongoDB Simple operation