Skip to content

Commit 8916500

Browse files
authored
Update field-level-encryption.md
As of version 6 of the mongodb driver, ClientEncryption all useful public APIs formerly exposed from mongodb-client-encryption have been moved into the driver and should now be imported directly from the driver. Added keyAltNames as an example as it is useful for doing key lookups.
1 parent 9dc416a commit 8916500

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/field-level-encryption.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ Keep in mind that the following example is a simple example to help you get star
3939
The encryption key in the following example is insecure; MongoDB recommends using a [KMS](https://www.mongodb.com/docs/v5.0/core/security-client-side-encryption-key-management/).
4040

4141
```javascript
42-
const { ClientEncryption } = require('mongodb-client-encryption');
42+
const { ClientEncryption } = require('mongodb');
43+
// const { ClientEncryption } = require('mongodb-client-encryption'); As of version 6, ClientEncryption is moved to main mongodb driver.
4344
const mongoose = require('mongoose');
44-
const { Binary } = require('mongodb');
4545

4646
run().catch(err => console.log(err));
4747

@@ -66,12 +66,14 @@ async function run() {
6666
kmsProviders
6767
}
6868
}).asPromise();
69-
const encryption = new ClientEncryption(conn.client, {
69+
const encryption = new ClientEncryption(conn.getClient(), {
7070
keyVaultNamespace,
7171
kmsProviders,
7272
});
7373

74-
const _key = await encryption.createDataKey('local');
74+
const _key = await encryption.createDataKey('local', {
75+
keyAltNames: ['exampleKeyName'],
76+
});
7577
}
7678
```
7779

0 commit comments

Comments
 (0)