Skip to content

Commit 7dcb994

Browse files
committed
Generate 'keyId' automatically
1 parent 2f305ca commit 7dcb994

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

source/includes/qe-tutorials/php/queryable-encryption-helpers.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ function createEncryptedCollection(
190190
): void
191191
{
192192
try {
193+
// This should be done in the createEncryptedCollection method
194+
foreach ($encryptedFieldsMap['encryptedFields']['fields'] as &$field) {
195+
if (!isset($field['keyId'])) {
196+
$keyId = $clientEncryption->createDataKey($kmsProviderName, $customerMasterKeyCredentials);
197+
$field['keyId'] = $keyId;
198+
}
199+
}
200+
193201
// start-create-encrypted-collection
194202
$client->getDatabase($encryptedDatabase)->createEncryptedCollection(
195203
$encryptedCollectionName,

0 commit comments

Comments
 (0)