KeyVault.deleteKey(UUID)지정된 UUID를 가진 데이터 암호화 키를 데이터베이스 연결에 연결된 키 모음에서 삭제합니다.
반환합니다: 삭제된 키의 개수를 나타내는 문서입니다.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
- 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.
암호화된 클라이언트 만들기
Mongo() 생성자를 클라이언트 사이드 필드 수준 암호화 옵션과 함께 사용하여 데이터베이스 연결을 생성합니다. mongodb://myMongo.example.net URI를 대상 cluster의 연결 문자열 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 }