Docs Menu

HexData()

Creates a binary data object from hexadecimal data.

HexData()の構文は次のとおりです。

HexData( <subType>, <buffer> )
次の値を返します。Binary data object.

このコマンドは、次のフィールドを取ります。

フィールド
タイプ
必要性
説明

subType

integer

必須

Specify a data subtype:

番号
説明

0

汎用バイナリのサブタイプ

1

関数データ

2

バイナリ(旧)

3

UUID(旧)

4

UUID

5

MD5

6

暗号化された BSON 値

7

圧縮された時系列データ

バージョン 5.2 で追加

8

キーやシークレットなどの機密データ。 MongoDB では、サブタイプ 8 のバイナリ データのリテラル値はログに記録されません。代わりに、MongoDB は###のプレースホルダー値をログに記録します。

9

ベクトルデータとは、同じ型の数値が高密度に圧縮された配列です。

128

カスタム データ

buffer

string

必須

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.

1

使用 HexData() to insert a document with binary data created from a hexadecimal string into a test collection:

db.hexCollection.insertOne( {
_id: 0, hexField: HexData( 0, "123456abcdef" )
} )
2

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) } ]