当前位置:网站首页>21 days learning mongodb notes
21 days learning mongodb notes
2022-04-23 12:42:00 【Saidywin】
Install local MongoDB
stay bin Under the path of mongod --dbpath c:\data\db
perform MongoDB Code for :
> 2 + 2
4
> db
test
> db.runoob.insert({x:10})
WriteResult({ "nInserted" : 1 })
> db.runoob.find()
{ "_id" : ObjectId("625eaa86311de6f041f0ac26"), "x" : 10 }
> use mydb
switched to db mydb
> db
mydb
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
test 0.000GB
> db.movie.insert({"name":"tutorials point"})
WriteResult({ "nInserted" : 1 })
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
mydb 0.000GB
test 0.000GB
> use mydb
switched to db mydb
> db.createCollection("mycollection")
{ "ok" : 1 }
> show collections
movie
mycollection
> db.createCollection("mycol", { capped : true, autoIndexID : true, size : 6142800, max : 10000 } )
{
"ok" : 0,
"errmsg" : "BSON field 'create.autoIndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> db.createCollection("mycol", { capped : true, autoIndexID : true, size : 6142800, max : 10000 } )
{
"ok" : 0,
"errmsg" : "BSON field 'create.autoIndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> db.createCollection("mycol",{capped :true, autoIndexID:true, size : 614800\, max:10000})
uncaught exception: SyntaxError: invalid escape sequence :
@(shell):1:74
> db.createCollection("mycol",{capped :true, autoIndexID:true, size : 614800, max:10000})
{
"ok" : 0,
"errmsg" : "BSON field 'create.autoIndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> use mydb
switched to db mydb
> db.createCollection("mycol", { capped : true, autoIndexID : true, size : 6142800, max : 10000 } )
{
"ok" : 0,
"errmsg" : "BSON field 'create.autoIndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> db.createCollection("mycol",{capped :true, autoIndexID:true, size : 614800, max:10000})
{
"ok" : 0,
"errmsg" : "BSON field 'create.autoIndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> show collections
movie
mycollection
> db.createCollection("mycol",{capped :true, size : 614800, max:10000})
{ "ok" : 1 }
> db.createCollection("mycol",{capped :true, ndexID:true, size : 614800, max:10000})
{
"ok" : 0,
"errmsg" : "BSON field 'create.ndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> db.createCollection("mycol",{capped :true, ndexID:true, size : 614800, max:10000})
{
"ok" : 0,
"errmsg" : "BSON field 'create.ndexID' is an unknown field.",
"code" : 40415,
"codeName" : "Location40415"
}
> show collections
movie
mycol
mycollection
> show collections
movie
mycol
mycollection
>
MongoDB The following data types are supported :
- String: character string . Data types commonly used to store data . stay MongoDB in ,UTF-8 The encoded string is legal .
- Integer: Integer values . For storing values . Depending on which server you use , Can be divided into 32 Bit or 64 position .
- Boolean: Boolean value . Used to store Boolean values ( really / false ).
- Double: Double precision floating point value . Used to store floating point values .
- Min/Max keys: Combine a value with BSON( The binary JSON) The ratio of the lowest value of an element to the highest value .
- Arrays: Used to store an array or list or values as a key .
- Timestamp: Time stamp . Record when the document was modified or added .
- Object: Used for embedded documents .
- Null: Used to create a null value .
- Symbol: Symbol . This data type is basically the same as the string type , But the difference is , It is commonly used in languages with special symbol types .
- Date: Date time . use UNIX Time format to store the current date or time . You can specify your own time and date : establish Date object , Incoming year, month and day information .
- Object ID: object ID. For creating documents ID.
- Binary Data: binary data . Used to store binary data .
- Code: Code type . Used for storage in documents JavaScript Code .
- Regular expression: Regular expression type . Used to store regular expressions .
SQL The term / Concept | MongoDB The term / Concept | explain / explain |
---|---|---|
database | database | database |
table | collection | Database table / aggregate |
row | document | Data record row / file |
column | field | Data field / Domain |
index | index | Indexes |
table joins | Table joins ,MongoDB I won't support it | |
primary key | primary key | Primary key ,MongoDB Automatically put _id Field sets the primary key |
版权声明
本文为[Saidywin]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231239425864.html
边栏推荐
- Buuctf Web [bjdctf2020] zjctf, but so
- 免费试用一个月的服务器,并附上教程
- Message queuing overview
- Redis deployment of cloud native kubesphere
- 【蓝桥杯】4月17日省赛刷题训练(前3道题)
- Analysis of InnoDB execution process in MySQL
- Try the server for one month for free, and attach the tutorial
- Trier les principales utilisations de l'Agent IP réseau
- 栈和队列a
- 【csnote】ER图
猜你喜欢
QT one process runs another
A graphic designer's fantasy world | ones characters
实现一个盒子在父盒子中水平垂直居中的几种“姿势”
Idea setting copyright information
基于卷积神经网络的遥感影像分类识别系统
Qt双缓冲绘图
一个平面设计师的异想世界|ONES 人物
Object.keys后key值数组乱序的问题
Dialogue with Bruce, author of PostgreSQL: "changing careers" is to better move forward
QT draw text
随机推荐
Qt重绘事件与剪切
C, calculation code of parameter points of two-dimensional Bezier curve
On using go language to create websocket service
QT double buffer drawing
Kubernetes 入門教程
STM32 project transplantation: transplantation between chip projects of different models: Ze to C8
flask项目跨域拦截处理以及dbm数据库学习【包头文创网站开发】
Debug Jest test cases in VSCode, debug Jest test cases in VSCode, middle note basedir=$(dirname "$" (echo "$0" sed -e -e, s, \ \, / "-e").
QT redraw events and cuts
Idea setting copyright information
Buuctf Web [bjdctf2020] zjctf, but so
Message queuing overview
STM32CubeProgrammer基础使用说明
Introduction to metalama 4 Use fabric to manipulate items or namespaces
传统企业如何应对数字化转型?这些书给你答案
天梯赛赛前练习
31岁才转行程序员,目前34了,我来说说我的经历和一些感受吧...
box-sizing
航芯技术分享 | ACM32 MCU安全特性概述
SSM框架系列——注解开发day2-2