MongoDB authoritative Guide to Learning Notes (2)-Getting Started

Source: Internet
Author: User
Tags mongodb regular expression

The concept comparison between MongoDB and relational database:

                         MongoDB                relational database
                          document                       row
                          collection                       table
                          instance                    n Database

1. Documentation

Document: Multiple keys and their associated values are placed together in an orderly manner. JS, the document is represented as an object.

{"Key": "Value"}
{"Name": "Zhangsan", "Age": 20}

2. Collection

Collection: A set of documents is a collection. Collections are modeless (different types of documents can be in a collection). To enhance flexibility and ease of management, you need to create a pattern to bring together documents of the relevant type.

Specification for collection naming: non-null, not "system." Beginning Non-$

3. Database

Namespace (fully qualified name): Database name. Collection name. Subset Name

4. Start, use 27017 port

ubuntu:$./mogod
Windows:mogod.exe

5. Run the shell

$./mongo

6.shell command

Select Database

>use Foo

Create

>db.user.insert ({"Name": "Zhangsan", "Age": 20})

Read

>db.user.find ()

Update

>db.user.update ({"Name": "Zhangsan"},{"gender": "Male"})

Delete

>db.user.remove ({"Name": "Zhangsan"})

Data type ('-' means not supported in shell)
Null Boolean; 64 floating point; string;
Symbol-; object ID; A date; a regular expression;
JS code; Binary data-; maximum/small value-;
Not defined; an array; an inline document.

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.