Mongodb+mongovue installation and Getting StartedTransfer from CSDN
-
-
- Preface and Concept
- Environment installation
- The installation of MongoDB
- Mongovue Installation
- Establish a connection
- Basic operations
- Create a table
- Add data
- Inquire
- Date Query
- Sorting sort
- Query field fields
- Skip Skipping
- Limit paging
- Modify
- Delete data
Preface and Concept
It is said that Nodejs and MongoDB is a pair of good friends, so they can not help learning to understand some of the mongodb related things, then, what is MongoDB? Here are five things that every open person should know:
MongoDB is a standalone server;
- Like MySQL or Postresql, MongoDB provides a listening port for access. It provides tools for querying, creating, updating, and deleting. In theory, you work with it the same way: Connect, perform tasks, and close connections
It is document-based, not table-based;
MongoDB does not have a structured language. If you want to create a new document type, you don't have to do anything to tell the database about the structure of the data, but just save it in the database.
To put it simply, MongoDB uses a type of processing style like JavaScript or PHP. In other words, the database is a flexible, weakly typed type.
While some of the data is restrictive (chunks of data may require some explicit processing), in most cases you can write your MongoDB code just like you would write PHP code.
It is unstructured;
- Remember these layers of database abstraction you wrote? Remember the ORM layers you handled? Now you can discard all of them. You don't need them in MongoDB. MongoDB does not have many query statements. In most cases, just give it an array to specify the information you want, and then it will give you an array of returned documents. If you want to run some very complex queries (such as the map-reduce operation), you can pass JavaScript to MongoDB, whose internal JavaScript engine can parse the script
No need to learn another query language;
Development time is also short because there is no structure to manage and little (if any) data maps.
The learning curve is smooth because there is no new query language to learn. The code is concise. After all, without any other ORM, encapsulation can be very simple. Your code is the guarantee of the future. It's easy to add more fields to your object. So the requirements change and you can quickly modify the code to fit in.
MongoDB is enough to make me realize that it has the potential to change the rules of the game. This is why you want to use a new generation of document databases instead of SQL-based relational databases. Leaving relational databases in the dust is more likely to allow them to do what they can do: store data that belongs to rows and tables.
MongoDB is a document-oriented database developed in C + +, that is, anti-traditional database paradigm to design, the related objects are recorded in a document, each document is Schema-free, that is, the column name can be freely defined, more flexible, Especially in the face of the business logic of the application scenario is very dynamic. The data is stored in Bson (JSON-like) binary format. The downside is the possibility of some data redundancy and storage overhead.
In addition, MongoDB's indexing mechanism is the same as a database such as MySQL, and can leverage the experience of a traditional relational database to use the MongoDB index.
Unlike many other NoSQL products developed by individual engineers based on the application scenario, MongoDB has a dedicated company 10gen to maintain. One thing to note is that MongoDB itself is not managing memory, can not specify memory size, completely to the operating system to manage, so sometimes is not controllable, in the production environment use must monitor memory usage at the OS level.
It has powerful mainstream development language support such as C #, C + +, Java, PHP, Perl, Python, Ruby.
Installation of the environment installation MongoDB
- Download MongoDB
MongoDB website Address
Personal Baidu Cloud Disk address, version: Mongodb-win32-x86_64-2008plus-ssl-v3.0-latest-signed.msi
installation
MongoDB has been installed successfully here.
Create a folder to store data
For example, create a data folder under D that is used to load the information.
Specify the data store path and start the service
- Under CMD, enter the path just MONGODB installation, such as:
- Start the service
Execution instructions: Mongod–dbpath D:\data, where D:\data is the location where the data is stored. If this starts successfully.
- Verify that the service is started
Open in Browser: http://localhost:27017/, the service has started successfully if the effect has occurred:
Mongovue Installation
Download Mongovue
Personal network Disk Download
After downloading the decompression effect as follows:
installation
Such as:
Not much to explain, to this Mongovue has been installed to complete.
cracked
Replace the "MongoVUE.exe" file in the "Cracked Patches" folder under the Unzip zip to the installation file directory, such as:
Replace to
To this, the hack has been completed.
Establish a connection
Basic Operations
Create a table
Add Data
Select the table you just added, right-click, select Insert/import Documents, such as:
View Log Log
db.Test.insert({ Name:"张三", Age:23, Sex:"男", Add:"XXX市XXX号XXX街道XXX号"});
Enquiry
Date Query
Sort ${sort}
- For example, enter Json:{age:-1} in ${sort} to sort the age field:
Note: In ascending order when greater than 0, less than 0 is descending
db.Test.find({ "$where" : "this.Age==23 || this.Age==50" }).limit(50).sort({ "Age" : -1 });
db.Test.find({ "$where" : "this.Age==23 || this.Age==50" }).limit(50).sort({ "Age" : -1 }).explain();
query field ${fields}
For example, query _id and these fields {name:1,age:1}
Db. Test. Find ({"$where":"This. age==23 | | This. Age==50 "}, {"Name":1, "age": 1}) .limit (50) .sort ({ Span class= "hljs-string" > "age":-1}) ;d b.find ({ "$where": "this. age==23 | | This. Age==50 "}, {" Name ": 1, " age ": 1}) .limit (50) .sort ({" age ":-1}) .explain ()
Note: When equals 1, it is the field that queries _id and equals 1, and when it equals 0 o'clock, it is the query except for fields equal to 0, such as:
Db. Test. Find ({"$where":"This. age==23 | | This. Age==50 "}, {"Name":0, "age": 0}) .limit (50) .sort ({ Span class= "hljs-string" > "age":-1}) ;d b.find ({ "$where": "this. age==23 | | This. Age==50 "}, {" Name ": 0, " age ": 0}) .limit (50) .sort ({" age ":-1}) .explain ()
Skip Skipping
- When skip>0 indicates how many rows are skipped, such as skip=1, the table has 2 data together, then only the second data is queried.
Limit Paging
- Indicates how many rows are queried each time, 0 identifies the query, and >0 queries the specified number of rows.
Modify
Right-click the table, check update
db.Test.update({ "Age" : 24, "$isolated" : "true" },{$set:{Age:27,}});db.Test.find({Age:24});
Delete Data
Right-click on the table, select Remove, enter the following JSON in the window to complete the deletion
db.Test.remove({ "Age" : 26 });
Over, followed by further research, continuous improvement ...
Mongodb+mongovue installation and Getting Started