Skip to content

Commit dc5e924

Browse files
authored
DOCSP-49031 UUID (#1072)
* DOCSP-48717 UUID * DOCSP-49031 UUID * edits * edit import * edit * edit * JS review * tech review
1 parent f6d2caa commit dc5e924

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

source/data-formats/bson.txt

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ In this guide, you can learn how to create BSON documents, read BSON from a file
2020
and write BSON to a file by using the {+driver-short+}.
2121

2222
**BSON**, or Binary JSON, is the data format that MongoDB uses to organize
23-
and store data. This data format includes all JSON data structure types and
24-
adds support for types including dates, different size integers, ObjectIds, and
25-
binary data. You can use BSON documents in your {+language+} application by importing the
26-
BSON package. For a complete list of supported types, see the
27-
:manual:`BSON Types </reference/bson-types>` server manual page.
23+
and store data. You can use BSON documents in your {+language+} application
24+
by importing the BSON package.
2825

2926
The code samples in this guide use the following BSON document as an example:
3027

@@ -40,6 +37,27 @@ The code samples in this guide use the following BSON document as an example:
4037
"name" : "Mongo's Pizza"
4138
}
4239

40+
BSON Data Types
41+
---------------
42+
43+
BSON supports all JSON data structure types and adds support for types including
44+
dates, different size integers, ``ObjectId``, and binary data. For a complete list of
45+
supported types, see the :manual:`BSON Types </reference/bson-types>` page in the
46+
{+mdb-server+} Manual.
47+
48+
Universally Unique IDs (UUIDs)
49+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50+
51+
The {+driver-short+} supports UUIDs by using the BSON Binary subclass ``UUID``. You
52+
can create a ``UUID`` object by using the ``UUID()`` constructor. The following code
53+
example generates a random UUID:
54+
55+
.. code-block:: javascript
56+
57+
import { UUID } from 'mongodb';
58+
59+
const myUuid = new BSON.UUID();
60+
4361
Create a BSON Document
4462
----------------------
4563

@@ -137,5 +155,7 @@ API Documentation
137155
-----------------
138156

139157
To learn more about any of the methods or types discussed in this
140-
guide, see the `BSON <{+api+}/modules/BSON.html>`__ API documentation.
158+
guide, see the following API documentation:
141159

160+
- `BSON <{+api+}/modules/BSON.html>`__
161+
- `UUID <{+api+}/classes/BSON.UUID.html>`__

0 commit comments

Comments
 (0)