You are viewing an offline version of MongoDB documentation. Some page features might be unavailable. To view the latest version of the page or use interactive features, visit the live page.
HexData()
Definition
Creates a binary data object from hexadecimal data.
Syntax
HexData()
has the following syntax:
Command Fields
The command takes these fields:
Field | Type | Necessity | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| integer | Required | Specify a data subtype:
| ||||||||||||||||
| string | Required | Hexadecimal data. The string is decoded up to the first character that is not a valid hexadecimal digit. You can use upper or lower case letters in the hexadecimal string. |
Examples
1
2
Retrieve the document
To return the document, run the following find
command:
db.hexCollection.find()
Output shows the hexField
value as a base 64 number using
Binary.createFromBase64()
:
[ { _id: 0, hexField: Binary.createFromBase64('EjRWq83v', 0) } ]