1. Create a DataSet:
A. Creating a default dataset that does not set parameters (default dataset comes with a pipelining id,_id)
// Create a default collection
B. Creating a dataset with the specified parameters
false true, size:6142800, max:10000}) // Create specified parameter collection
Capped if true, the CAP collection is enabled and the subsequent update is unsuccessful
Specify parameter: capped Boolean (optional) If true, the CAP collection is enabled. A capped collection is a fixed-size collection that automatically overwrites the oldest entry when it reaches its maximum size. If True is specified, the dimension parameter needs to be specified as well.
Autoindexid Boolean (optional) If true, the default value for the auto-create index _id field is false.
Size number (optional) specifies the maximum size of the byte cap collection. If the cap is true, then you also need to specify this field.
Max Number (optional) specifies the maximum amount that the capping collection allows in the file.
2. Display a list of data sets:
Show collections
3. Delete the data set:
Db.mycol.drop ()
4. Insert a record, incidentally create a dataset (created by default): (If no user dataset is automatically created with a user dataset)
Db.user.insert ({"Email": "[email protected]"}) Db.user.insert ({email:' [Email protected] ', pwd:' AA ', Nicheng:' Donglixia ', Age:20}) Db.user.insert ([{email:' [Email protected] ', pwd:' AA ', Nicheng:' Donglixia ', Age:26}, {email:' [Email protected] ', pwd:' BB ', Nicheng:' Donglixia ', Age:27}, {email:' [Email protected] ', pwd:' CC ', Nicheng:' Donglixia ', Age:28 }, ])
5. View the data set:
Db.mycol.find () Db.mycol.find (). Pretty ( ) // format Display db.mycol.findOne () // return a record
6. Delete records:
Db.mycol.remove ({})
Attached: Data type
Data type
String: This is the most commonly used data type to store data. The string in MongoDB must be a valid UTF-8.
? Integer: This type is used to store a numeric value. The integer can be either 32-bit or 64-bit, depending on your server.
? Boolean: This type is used to store a Boolean value (True/false).
? Double: This type is used to store floating-point values.
? Min/max keys: This type is used to compare the lowest and highest values of the Bson element.
? Arrays: Use this type of array or list or multiple values to store to a key.
? Timestamp: Timestamp. This makes it easy to record when the file has been modified or added.
? Object: This data type is used for embedded files.
? Null: This type is used to store a null value.
? Symbol: This data type is used for the same string, but it is usually reserved for languages of a particular symbol type.
? Date: This data type is used to store the UNIX time format for the current date or time. You can specify your own date and time, date and year, month, day to create an object.
? Object ID: This data type is used to store the document ID.
? Binary data: This data type is used to store binaries.
? Code: This data type is used to store JavaScript code in the document.
? Regular expression: This data type is used to store regular expressions
MongoDB Operational Data Collection