Understanding the MongoDB Database

Source: Internet
Author: User
Tags install mongodb

MongoDB has three triples: a database , a collection , a document , where "collection" corresponds to the "table" in the relational database, and "document" corresponds to "row".

Install MongoDB: Go to the official website to download the corresponding system MongoDB compression package, after extracting the folder renamed to MongoDB (if installed to D disk), and in the MongoDB Folder New Blog folder (equivalent to create a database, blog for the database name) As the storage directory for the project content.

Open a command-line window and go to the bin directory to execute the command:

Mongod--dbpath. /blog/

The command means to set the blog folder as the project's storage directory and start the database.

Open a cmd again, enter the MONGO command to open the shell, the shell is the client of MongoDB, the default connection is the "test" database.

Set a collection called "person" (the relational database is equivalent to establishing a table named person)

Inserting Data

Db.person.insert () Db.person.insert ({"Name": "lbs", "Age": Ten}) Db.person.insert ({"Name": "CCX", "Age": 10})

  Find data

Db.person.find () db.person.find ({"Name": "lbs"})//Find the document named lbs in the Person collection Db.person.find ()//without the parameters find all documents in the person collection $ GT: Greater Than (>) $gte: Greater Than or equal to (>=) $lt: Less Than (<) $lte: less than or equal to (<=) $ne: Not equal to (! =) $in: Contains $nin: does not contain $or: or

  Update data

Delete Data

Understanding the MongoDB Database

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.