MongoDB journey (iii) basic management (MongoDBJavascriptShell): showdbs; showcollections; db. stats (); db. members. stats (); db. runCommand ({dbstats: 1}); db. runCommand ({collstats: 1}); db. runCommanddb. $ cmd. findOnedb. el
MongoDB journey (iii) basic management (MongoDB Javascript Shell) the following methods can be used to obtain database information: show dbs; show collections; db. stats (); db. members. stats (); db. runCommand ({dbstats: 1}); db. runCommand ({collstats: 1}); db. runCommand = db. $ cmd. findOne db. el
MongoDB journey (iii) basic management (MongoDB Javascript Shell)
You can obtain database information in the following ways:
Show dbs; show collections;
Db. stats (); db. members. stats (); db. runCommand ({dbstats: 1}); db. runCommand ({collstats: 1 });
Db. runCommand = db. $ cmd. findOne
Db. help ();
In addition, shell also has a built-in Tab incomplete mechanism;
Db. numbers. save; // view the internal implementation of the save method.
Others:
Object ID generation:
Each set must be unique for all documents, and the primary key is stored in the _ id field of the document. It consists of 12 bytes of specific structure. Id = 4-byte timestamp (Unix timestamp) + 3-byte machine ID + 2-byte process ID + 3-byte counter. For example: 4c291865 238d3b 19b2 000001. Most drivers are allowed to provide this timestamp, providing the creation time, accurate to the nearest second.
BSON:
It is both the storage format and Command Format of MongoDB. All documents are stored on the disk in BSON format, and all queries and commands are specified by BSON documents. Therefore, all MongoDB drivers must be converted between language-specific document descriptions and BSON.
The BSON specification contains 19 types.
The core functions of the database driver are as follows: Create an ID, serialize BSON, and communicate with the database server.