当前位置:网站首页>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
边栏推荐
猜你喜欢

31岁才转行程序员,目前34了,我来说说我的经历和一些感受吧...

力扣刷题之完全二叉树的节点个数

STM32 control stepper motor (ULN2003 + 28byj)
![[daily question] chessboard question](/img/70/54a924d07c935965e54b96d9b07278.png)
[daily question] chessboard question

大家帮我看一下这是啥情况,MySQL5.5的。谢了

Recommended programming AIDS: picture tool snipaste

如何防止网站被黑客入侵篡改

SPSS之单因素方差分析

Idea的src子文件下无法创建servlet

A graphic designer's fantasy world | ones characters
随机推荐
Kubernetes 入门教程
[daily question] chessboard question
万事有你 未来可期 | ONES 2022校园招聘正式开启
Analysis of InnoDB execution process in MySQL
SPSS之单因素方差分析
C set Logo Icon and shortcut icon
AD20补充笔记3—快捷键+持续更新
STM32 project transplantation: transplantation between chip projects of different models: Ze to C8
[csnote] ER diagram
SynchronousQueue 源码解析
【每日一题】棋盘问题
一个平面设计师的异想世界|ONES 人物
I changed to a programmer at the age of 31. Now I'm 34. Let me talk about my experience and some feelings
风尚云网学习-input属性总结
使用Source Insight查看编辑源代码
php生成json处理中文
leetcode:437. Path sum III [DFS selected or not selected?]
BUUCTF WEB [BJDCTF2020]The mystery of ip
How does sqlserver insert or update the number of weeks of the day instead of text
网络信息安全之零信任