兼容性
此命令可用于以下环境中托管的部署:
- MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
deleteKey() 通过以下语法实现:
keyVault = db.getMongo().getKeyVault() keyVault.deleteKey(UUID("<UUID String>"))
The UUID is a BSON binary data object with subtype 4.
行为
需要在数据库连接上配置客户端字段级加密
The mongosh client-side field level encryption methods require a database connection with client-side field level encryption enabled. If the current database connection was not initiated with client-side field level encryption enabled, either:
Use the
mongoshcommand line options to establish a connection with the required options. The command line options only support the Amazon Web Services KMS provider for CMK management.
例子
The following example is intended for rapid evaluation of client-side field level encryption. For specific examples of using KeyVault.deleteKey() with each supported KMS provider, see Delete a Data Encryption Key.
Retrieve the KeyVault object and use the KeyVault.deleteKey() method to delete the data encryption key with matching UUID:
keyVault = encryptedClient.getKeyVault() keyVault.deleteKey(UUID("b4b41b33-5c97-412e-a02b-743498346079"))
If successful, deleteKey() returns output similar to the following:
{ "acknowledged" : true, "deletedCount" : 1 }
提示