KeyVault.deleteKey(UUID)指定された UUID を持つデータ暗号化キーを、データベース接続に関連付けられたキーヴォールトから削除します。
deleteKey()の構文は次のとおりです。keyVault = db.getMongo().getKeyVault() keyVault.deleteKey(UUID("<UUID String>")) UUID は、サブタイプ
4を持つ BSONbinary dataオブジェクトです。次の値を返します。 削除されたキーの数を示すドキュメント。
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
動作
データベース接続にクライアント側のフィールドレベル暗号化を構成する必要があります
The mongosh ClientEncryption methods require a database connection with in-use encryption enabled. If the current database connection was not initiated with in-use 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.
暗号化されたクライアントの作成
データベース接続を作成するには、クライアント側のフィールドレベル暗号化オプションが構成されたMongo()コンストラクターを使用します。 mongodb://myMongo.example.net URI を、ターゲットクラスターの接続string URIに置き換えます。
encryptedClient = Mongo( "mongodb://myMongo.example.net:27017/?replSetName=myMongo", autoEncryptionOpts )
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 }
Tip