Skip to content

Commit f346b50

Browse files
authored
* DOCSP-4651 Adding binData constructor * structure of bindata page * * * add additional examples * terminology * * * del * add * ** * *** * remove * add * IR 1 * * * IR 2 * formatting table * update example * XR1 * link * an * build errors * * * *
1 parent 57c6fc8 commit f346b50

File tree

4 files changed

+151
-3
lines changed

4 files changed

+151
-3
lines changed

source/reference/method.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,10 @@ Constructors
11401140

11411141
- Description
11421142

1143+
* - :method:`BinData()`
1144+
1145+
- Returns a binary data object.
1146+
11431147
* - :method:`BulkWriteResult()`
11441148

11451149
- Wrapper around the result set from :method:`Bulk.execute()`.

source/reference/method/BinData.txt

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
.. _server-binData-method:
2+
3+
=========
4+
BinData()
5+
=========
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Definition
16+
----------
17+
18+
Creates a binary data object.
19+
20+
``BinData`` has the following syntax:
21+
22+
.. method:: BinData(<sub_type>,<buffer>)
23+
24+
.. list-table::
25+
:header-rows: 1
26+
:widths: 20 20 60
27+
28+
* - Parameter
29+
30+
- Type
31+
32+
- Description
33+
34+
* - ``sub_type``
35+
36+
- string
37+
38+
- The binary type.
39+
40+
.. list-table::
41+
:header-rows: 1
42+
:widths: 40 60
43+
44+
* - Subtype
45+
- Description
46+
47+
* - 0
48+
49+
- Generic binary subtype
50+
51+
* - 1
52+
53+
- Function
54+
55+
* - 2
56+
57+
- Byte Array
58+
59+
* - 3
60+
61+
- OLD UUID
62+
63+
* - 4
64+
65+
- UUID
66+
67+
* - 5
68+
69+
- MD5
70+
71+
* - 128
72+
73+
- User defined
74+
75+
* - ``buffer``
76+
77+
- string
78+
79+
- The buffer object containing binary data, must be a base 64 encoded string value.
80+
81+
:returns: A binary data object.
82+
83+
Examples
84+
--------
85+
86+
Insert a ``BinData()`` Object
87+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88+
89+
Use the ``BinData()`` constructor to create the ``bdata`` variable.
90+
91+
.. code-block:: javascript
92+
93+
var bdata = BinData(0, "gf1UcxdHTJ2HQ/EGQrO7mQ==")
94+
95+
Insert the object into the ``testbin`` collection.
96+
97+
.. code-block:: javascript
98+
99+
db.testbin.insertOne( { _id : 1, bin_data: bdata } )
100+
101+
Query the ``testbin`` collection for the inserted document.
102+
103+
.. code-block:: javascript
104+
105+
db.testbin.find()
106+
107+
You can see the binary ``buffer`` stored in the collection.
108+
109+
110+
.. code-block:: javascript
111+
:copyable: false
112+
113+
{
114+
_id: 1,
115+
bin_data: Binary(Buffer.from("81fd547317474c9d8743f10642b3bb99", "hex"), 0)
116+
}
117+
118+
Get the Length of ``BinData()`` Object
119+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
120+
121+
Use the ``BinData()`` constructor to create the ``bdata`` variable.
122+
123+
.. code-block:: javascript
124+
125+
var bdata = BinData(0, "gf1UcxdHTJ2HQ/EGQrO7mQ==")
126+
127+
Use ``.length()`` to return the bit length of the object.
128+
129+
.. code-block:: javascript
130+
131+
bdata.length()
132+
133+
The returned value is:
134+
135+
136+
.. code-block:: javascript
137+
:copyable: false
138+
139+
16

source/reference/method/ObjectId.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
========
2-
ObjectId
3-
========
1+
==========
2+
ObjectId()
3+
==========
44

55
.. default-domain:: mongodb
66

source/reference/method/js-constructor.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Object Constructors and Methods
2020

2121
- Description
2222

23+
* - :method:`BinData()`
24+
25+
- Returns a binary data object.
26+
2327
* - :method:`BulkWriteResult()`
2428

2529
- Wrapper around the result set from :method:`Bulk.execute()`.
@@ -65,6 +69,7 @@ Object Constructors and Methods
6569
:titlesonly:
6670
:hidden:
6771

72+
/reference/method/BinData
6873
/reference/method/BulkWriteResult
6974
/reference/method/Date
7075
/reference/method/ObjectId

0 commit comments

Comments
 (0)