@@ -103,9 +103,10 @@ ref: create-a-data-encryption-key
103103level : 4
104104content : |
105105 Construct a client with the MongoDB connection string and key vault
106- namespace configuration, and create a data encryption key with the
107- following **code snippet**. The key vault in
108- this example uses the ``encryption`` database and ``__keyVault`` collection.
106+ namespace configuration, create a unique index on the ``keyAltNames`` field
107+ in that collection, and create a data encryption key with the following
108+ **code snippet**. The key vault in this example uses the ``encryption``
109+ database and ``__keyVault`` collection.
109110
110111 .. tabs-drivers::
111112
@@ -298,7 +299,10 @@ content: |
298299 :tabid: nodejs
299300
300301 .. code-block:: javascript
301- :emphasize-lines: 4
302+ :emphasize-lines: 7
303+
304+ const mongodb = require("mongodb")
305+ const { MongoClient, Binary } = mongodb
302306
303307 const connectionString = 'mongodb://localhost:27017/';
304308 const keyVaultDb = 'encryption';
@@ -316,7 +320,7 @@ content: |
316320 const keyDB = client.db(keyVaultDb);
317321 const keyColl = keyDB.collection(keyVaultCollection);
318322 const query = {
319- _id: base64KeyId,
323+ _id: new Binary(Buffer.from( base64KeyId, "base64"), 4) ,
320324 };
321325 const dataKey = await keyColl.findOne(query);
322326 console.log(dataKey);
0 commit comments