Ii. Introduction to MongoDB's basic knowledge

Source: Internet
Author: User
Tags mongodb client

1. Documents, collections, and databases

A), documentation: Because MongoDB is a document-oriented database, it is conceivable that the document is its basic unit, equivalent to the row in the relational database!

Ⅰ, which is an ordered set consisting of key-value pairs; Note: The key cannot be empty and is of type string.

Ⅱ, it is not only case-sensitive, but also distinguishes the data type;

Ⅲ,., and $ symbols have special meanings that need to be used in a particular environment;

b), collection: Similarly, multiple documents converge together as a collection, but these documents can be different structural patterns that are grouped together as tables in a relational database!

Ⅰ, same name cannot be empty, cannot start with system, and cannot use reserved character $;

Ⅱ, dynamic mode (different structural modes) can make the same collection contain a variety of document objects; For example, the first document in a collection is a student, and the second document is a commodity.

c), database: Similarly, a MongoDB instance can have multiple separate database objects, each of which is aggregated by n multiple collections!

Ⅰ, name cannot be empty, cannot contain/, \, ", *, <, >,:, | 、?、 $, (space) special characters, it is recommended to use letters and numbers in ASCII;

Ⅱ, database name is case-sensitive, all lowercase is recommended;

Ⅲ, its name is up to 64byte;

Ⅳ, the following database of special significance: admin (User database), local (database), Config (metabase)

2, MongoDB client-shell Introduction

A), it is called the JavaScript shell, it can use the command to interact with the MongoDB instance, it is a very important tool;

b), this is called it because it is a fully functional JavaScript interpreter, you can run arbitrary JavaScript programs;

c), through the shell can do four basic operations on the data: Create, read, update and delete (i.e. crud) operations;

3. Data type

A), the document is similar to the object in JavaScript, so it can be analogous to JSON, mainly including the following:

Ⅰ, a field that represents a null value or does not exist: null;

Ⅱ, Boolean type: Contains True and false;

Ⅲ, numeric type: floating-point value of 64-bit default in Shell

Ⅳ, String type: you know.

Ⅴ, Date type: new Date ();

Ⅵ, regular expression;

Ⅶ, arrays;

Ⅷ, inline document: Refers to the document can be nested other documents

Ⅸ, Object ID: Unique identifier of the document, is a 12byte ID

4, Shell combat operations

A) We have added the MongoDB service to the list of Windows services, and we can start directly from the form,

You can also start MongoDB services from the command net start MongoDB in the Administrator command Prompt (win+x+a).

b), win+r, enter cmd into the command prompt, switch to the bin directory of the MongoDB installation, and enter the command: Mongo.exe connection server;

c), Shell operations

Ⅰ Different documents:

Ⅱ, JavaScript functions:

Ⅲ, simple crud operations

PS: These are relatively simple commands, you can knock on it! Ha ha

Ii. Introduction to MongoDB's basic knowledge

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.