Mongodb+mongovue installation and Getting Started

Source: Internet
Author: User
Tags log log memory usage

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:

  1. 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
  2. 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.

  3. 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
  4. 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.

  5. 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
    • First open the Mongovue, as the process

Basic Operations Create a table
    • Right-click on the database to add Collection, such as:

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号"});
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
Enquiry
    • For the most basic query:  

      • basic query, enter JSON&NBSP in {find},
        such as: {Name: "Zhang San"} 
        db.find ({ "Name":  "Zhang San"}) Span class= "Hljs-preprocessor" >.limit (50) ;d b.find ({ "Name":  "Zhang San"}) Span class= "Hljs-preprocessor" >.limit (50) .explain () Span class= "Hljs-comment",                 
        • 1
        • 2
        • 1
        • 2
Date Query
  • The date needs to be formatted with the Isodate function, for example: {"Insertdate": Isodate ("2016-03-09t16:00:00z")}

    • Query greater than, less than, greater than or equal to, less than or equal to

      db.Test.find({ "Age" : { "$gt" : 50 } }).limit(50);db.Test.find({ "Age" : { "$gt" : 50 } }).limit(50).explain();
        • 1
        • 2
        • 1
        • 2
      \$lt:小于\$lte:小于等于\$gt:大于\$gte:大于等于
    • Right click on the table, click Find2, more than find a where, write expressions, such as:  

      db.find ({ "$where":  "this. age==23 | | This. Age==50 "}) .limit (50) ;d b< Span class= "Hljs-preprocessor". Test.find ({ "$where":  "this. age==23 | | This. Age==50 "}) .limit (50)  . Explain ()                 
      • 1
      • 2
      • 1
      • 2
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 ()          
      • 1
      • 2
      • 1
      • 2

    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 ()          
      • 1
      • 2
      • 1
      • 2
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});
      • 1
      • 2
      • 1
      • 2
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 });
      • 1
      • 1

Over, followed by further research, continuous improvement ...

Mongodb+mongovue installation and Getting Started

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.