没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
My Courses - MongoDB University
Lab: Create and Deploy an Atlas Cluster - MongoDB University
With
Username and Password
selected, create a user for your database with
the following username and password:
username:
m001-student
•
password:
m001-mongodb-basics
•
From <https://university.mongodb.com/mercury/M001/2022_May_10/chapter/Chapter_1
_What_is_MongoDB_/lesson/5f32deb504e9ffc01ac9586c/problem>
Atlas for leaning
Organizations | MongoDB Cloud Services
Wg3ku8u2
quc
MongoDB_
m001_W...
MongoDB_
m001_W...
b-ZECwkH_
rA
MongoDB_
m001_W...
ijwQD5l6T3
U
MongoDB_
m001_W...
MongoDB_
m001_Atl...
TODO - Mongo Db Course - M001: MongoDB Basics
2022
年
5
月
17
日
8:54
SLB DEV Page 1
MongoDB_
m001_Atl...
Course Stage:
FlmOCJDua
J0
user@M001# mongosh --version
0.6.1
user@M001# mongo --version
MongoDB shell version v4.4.3
Build Info: {
"version": "4.4.3",
"gitVersion": "913d6b62acfbb344dde1b116f4161360acd8fd13",
"openSSLVersion": "OpenSSL 1.1.1f 31 Mar 2020",
"modules": [],
"allocator": "tcmalloc",
"environment": {
"distmod": "ubuntu2004",
"distarch": "x86_64",
"target_arch": "x86_64"
}
}
user@M001# mongo "mongodb+srv://sandbox.85xxc.mongodb.net/myFirstDatabase" --username
m001-student
MongoDB shell version v4.4.3
Enter password:
connecting to: mongodb://sandbox-shard-00-01.85xxc.mongodb.net:27017,sandbox-
shard-00-00.85xxc.mongodb.net:27017,sandbox-
shard-00-02.85xxc.mongodb.net:27017/myFirstDatabase?
authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=atlas-u4ysx1-
shard-0&ssl=true
*** You have failed to connect to a MongoDB Atlas cluster. Please ensure that your IP whitelist
allows connections from your network.
Error: can't connect to new replica set master [sandbox-shard-00-01.85xxc.mongodb.net:27017],
err: AuthenticationFailed: bad auth : Authentication failed. :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
user@M001# mongo "mongodb+srv://sandbox.85xxc.mongodb.net/myFirstDatabase" --username
m001-student
MongoDB shell version v4.4.3
Enter password:
connecting to: mongodb://sandbox-shard-00-02.85xxc.mongodb.net:27017,sandbox-
shard-00-01.85xxc.mongodb.net:27017,sandbox-
shard-00-00.85xxc.mongodb.net:27017/myFirstDatabase?
authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=atlas-u4ysx1-
shard-0&ssl=true
Implicit session: session { "id" : UUID("aac9b87c-0f7c-4394-bd1a-aa2e5894244c") }
MongoDB server version: 5.0.8
WARNING: shell and server versions do not match
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
https://community.mongodb.com
MongoDB Enterprise atlas-u4ysx1-shard-0:PRIMARY>
Lab: Connect to your Atlas Cluster - MongoDB University =>
"LAUNCH IDE"
mongo "mongodb+srv://sandbox.85xxc.mongodb.net/myFirstDatabase" --username m001-student
You will be prompted to enter the password that you just created:
m001-mongodb-basics
•
From <https://university.mongodb.com/mercury/M001/2022_May_10/chapter/Chapter_1
_What_is_MongoDB_/lesson/5f32dec404e9ffc0285d7076/problem>
In this course you will find IDE labs in the following chapters:
Chapter 1: 1 lab at the end of the chapter.
•
Chapter 2: 1 lab, and 1 sandbox space at the end of the chapter.
•
Chapter 3: 1 sandbox space at the end of the chapter.
•
Chapter 4: 1 sandbox space at the end of the chapter.
•
Chapter 5: 1 sandbox space at the end of the chapter.
•
From <https://university.mongodb.com/mercury/M001/2022_May_10/chapter/Chapter_1
_What_is_MongoDB_/lesson/5f5c03c704e9ff039e32729b/lecture>
Optional reading:
JSON vs BSON
•
Read more about BSON
•
Have questions?
Visit the course discussion forum.
JSON And BSON | MongoDB
However, there are several issues that make JSON less than ideal for usage
inside of a database.
JSON is a text-based format, and text parsing is very slow
SLB DEV Page 2
JSON is a text-based format, and text parsing is very slow
1.
JSON’s readable format is far from space-efficient, another database
concern
2.
JSON only supports a limited number of basic data types
3.
In order to make MongoDB JSON-first, but still high-performance and general-purpose, BSON was
invented to bridge the gap: a binary representation to store data in JSON format, optimized for
speed, space, and flexibility. It
’
s not dissimilar from other interchange formats like protocol
buffers, or thrift, in terms of approach.
What is BSON?
BSON simply stands for “Binary JSON,” and that’s exactly what it was
invented to be. BSON’s binary structure encodes type and length
information, which allows it to be parsed much more quickly.
Since its initial formulation, BSON has been extended to add some optional
non-JSON-native data types, like dates and binary data, without which
MongoDB would have been missing some valuable support.
Languages that support any kind of complex mathematics typically have
different sized integers (ints vs longs) or various levels of decimal
precision (float, double, decimal128, etc.).
Not only is it helpful to be able to represent those distinctions in data
stored in MongoDB, it also allows for comparisons and calculations to
happen directly on data in ways that simplify consuming application code.
Does MongoDB use BSON, or JSON?
MongoDB stores data in BSON format both internally, and over the network,
but that doesn’t mean you can’t think of MongoDB as a JSON database.
Anything you can represent in JSON can be natively stored in MongoDB, and
retrieved just as easily in JSON.
The following are some example documents (in JavaScript / Python style
syntax) and their corresponding BSON representations.
Unlike systems that simply store JSON as string-encoded values, or binary-
encoded blobs, MongoDB uses BSON to offer the industry’s most powerful
indexing and querying features on top of the web’s most usable data
format.
For example, MongoDB allows developers to query and manipulate objects by
specific keys inside the JSON/BSON document, even in nested documents many
layers deep into a record, and create high performance indexes on those
same keys and values.
When using a MongoDB driver in your language of choice, it’s still
important to know that you’re accessing BSON data through the abstractions
available in that language.
Firstly, BSON objects may contain Date or Binary objects that are not
natively representable in pure JSON. Second, each programming language has
its own object semantics. JSON objects have ordered keys, for instance,
while Python dictionaries (the closest native data structure that’s
analogous to JavaScript Objects) are unordered, while differences in
numeric and string data types can also come into play. Third, BSON supports
a variety of numeric types that are not native to JSON, and each language
will represent these differently.
Check your
driver documentation
to make sure you understand how to best
access MongoDB BSON-backed data in your language to avoid confusion, and
get the most out of your MongoDB experience.
JSON vs BSON
JSON
BSON
Encoding
UTF-8 String
Binary
Data
String, Boolean,
String, Boolean, Number (Integer, Float,
SLB DEV Page 3
Data
Support
String, Boolean,
Number, Array
String, Boolean, Number (Integer, Float,
Long, Decimal128...), Array, Date, Raw Binary
Readabili
ty
Human and Machine
Machine Only
JSON and BSON are indeed close cousins by design. BSON is designed as a
binary representation of JSON data, with specific extensions for broader
applications, and optimized for data storage and retrieval.
One particular way in which BSON differs from JSON is in its support for
some more advanced types of data. JavaScript does not, for instance,
differentiate between integers (which are round numbers), and floating-
point numbers (which have decimal precision to various degrees).
Most server-side programming languages have more sophisticated numeric
types (standards include integer, regular precision floating point number
aka “float”, double-precision floating point aka “double”, and boolean
values), each with its own optimal usage for efficient mathematical
operations.
JSON and BSON are indeed close cousins by design. BSON is designed as a
binary representation of JSON data, with specific extensions for broader
applications, and optimized for data storage and retrieval.
One particular way in which BSON differs from JSON is in its support for
some more advanced types of data. JavaScript does not, for instance,
differentiate between integers (which are round numbers), and floating-
point numbers (which have decimal precision to various degrees).
Most server-side programming languages have more sophisticated numeric
types (standards include integer, regular precision floating point number
aka “float”, double-precision floating point aka “double”, and boolean
values), each with its own optimal usage for efficient mathematical
operations.
Start Developing with MongoDB
—
MongoDB Drivers
MongoDB C#/.NET Driver
—
MongoDB Drivers
JSON Schema | The home of JSON Schema (json-schema.org)
JSON Schema is a vocabulary that allows you to
annotate
and
validate
JSON
documents.
Benefits
Describes your existing data format(s).
•
Provides clear human- and machine- readable documentation.
•
Validates data which is useful for:
Automated testing.
○
Ensuring quality of client submitted data.
○
•
Getting Started Step-By-Step | JSON Schema (json-schema.org)
Understanding JSON Schema
—
Understanding JSON Schema 2020-12 documentation (json-
schema.org)
Learn | JSON Schema (json-schema.org)
Discussions
·
json-schema-org/community
·
GitHub
Specification | JSON Schema (json-schema.org)
Implementations | JSON Schema (json-schema.org)
GitHub - gregsdennis/json-everything: System.Text.Json-based support for all of your JSON needs.
Discussions
·
json-schema-org/community
·
GitHub
Validators
.NET
Json.NET Schema
2019-09, draft-07, -06, -04, -03
(AGPL-3.0-only)
○
JsonSchema.Net
2020-12, 2019-09, draft-07, -06
(MIT)
○
Schema generators
Schema generators need not support generating every schema keyword. For
schema generators, compatibility with a draft means that either:
Schemas produced explicitly set the draft with
$schema
•
Schemas produced lack
$schema
but are valid against the appropriate
meta-schema
•
For example, the only incompatibilities between draft-04 and draft-06
involve
exclusiveMinimum
,
exclusiveMaximum
, and
id
vs
$id
. If a generator does
SLB DEV Page 4
involve
exclusiveMinimum
,
exclusiveMaximum
, and
id
vs
$id
. If a generator does
not set
$schema
and does not ever emit those keywords, then it is
compatible with draft-06 even if it was written with draft-04 in mind.
From code
.NET
Json.NET (AGPL-3.0) - generates schemas from .NET types
○
NJsonSchema - (Ms-PL) - generates schemas from .NET types, see
issue
574
for draft-06+ support progress
○
JsonSchema.Net.Generation (MIT) - generates schemas from .NET
types
○
•
Data from schemas
.Net
JsonSchema.Net.DataGeneration (MIT) Data generation from JSON
schemas, powered by the Bogus testing data generation library.
○
•
Getting Started Step-By-Step | JSON Schema (json-schema.org)
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/product.schema.json",
"title": "Product",
"description": "A product from Acme's catalog",
"type": "object",
"properties": {
"productId": {
"description": "The unique identifier for a product",
"type": "integer"
},
"productName": {
"description": "Name of the product",
"type": "string"
},
"price": {
"description": "The price of the product",
"type": "number",
"exclusiveMinimum": 0
},
"tags": {
"description": "Tags for the product",
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
},
"dimensions": {
"type": "object",
"properties": {
"length": {
"type": "number"
},
"width": {
"type": "number"
},
"height": {
"type": "number"
}
},
"required": [ "length", "width", "height" ]
},
"warehouseLocation": {
"description": "Coordinates of the warehouse where the product is located.",
"$ref": "https://example.com/geographical-location.schema.json"
}
},
"required": [ "productId", "productName", "price" ]
}
{
"productId": 1,
"productName": "An ice sculpture",
"price": 12.50,
"tags": [ "cold", "ice" ],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
},
"warehouseLocation": {
"latitude": -78.75,
"longitude": 20.4
}
}
Understanding JSON Schema
—
Understanding JSON Schema 2020-12 documentation (json-
schema.org)
Where to begin?
This book uses some novel
conventions
for showing schema examples and relating
JSON Schema to your programming language of choice.
•
If you’re not sure what a schema is, check out
What is a schema?
.
•
The basics chapter should be enough to get you started with understanding the
core
JSON Schema Reference
.
•
When you start developing large schemas with many nested and repeated sections,
check out
Structuring a complex schema
.
•
json-schema.org has a number of resources, including the official specification
and tools for working with JSON Schema from various programming languages.
•
There are a number of
online JSON Schema tools
that allow you to run your own
•
SLB DEV Page 5
剩余159页未读,继续阅读
PanPan_003
- 粉丝: 14
- 资源: 71
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0