Definition定义
Creates a binary data object from hexadecimal data.从十六进制数据创建二进制数据对象。
Syntax语法
HexData() has the following syntax:具有以下语法:
HexData( <subType>, <buffer> )-
Returns:返回Binary data object.二进制数据对象。
Command Fields命令字段
The command takes these fields:该命令包含以下字段:
subType |
| ||||||||||||||||||||||||||
buffer |
Examples示例
1
Create the example collection创建示例集合
Use 使用HexData() to insert a document with binary data created from a hexadecimal string into a test collection:HexData()将包含从十六进制字符串创建的二进制数据的文档插入到测试集合中:
db.hexCollection.insertOne( {
_id: 0, hexField: HexData( 0, "123456abcdef" )
} )2
Retrieve the document检索文档
To return the document, run the following 要返回文档,请运行以下find command:find命令:
db.hexCollection.find()
Output shows the 输出使用hexField value as a base 64 number using Binary.createFromBase64():Binary.createFromBase64()将hexField值显示为基数64的数字:
[ { _id: 0, hexField: Binary.createFromBase64('EjRWq83v', 0) } ]