Skip to content

Commit 9a0a987

Browse files
Comments
1 parent 1c7c679 commit 9a0a987

File tree

5 files changed

+197
-191
lines changed

5 files changed

+197
-191
lines changed

.github/workflows/encryption-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: ['master']
66
pull_request:
7-
branches: [ 'master' ]
7+
branches: [ 'master', 'csfle' ]
88
workflow_dispatch: {}
99

1010
permissions:

lib/drivers/node-mongodb-native/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
exports.BulkWriteResult = require('./bulkWriteResult');
88
exports.Collection = require('./collection');
99
exports.Connection = require('./connection');
10+
exports.ClientEncryption = require('mongodb').ClientEncryption;

lib/model.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ const minimize = require('./helpers/minimize');
6969
const MongooseBulkSaveIncompleteError = require('./error/bulkSaveIncompleteError');
7070
const ObjectExpectedError = require('./error/objectExpected');
7171
const decorateBulkWriteResult = require('./helpers/model/decorateBulkWriteResult');
72-
const { ClientEncryption } = require('mongodb');
73-
72+
const driver = require('./driver');
7473
const modelCollectionSymbol = Symbol('mongoose#Model#collection');
7574
const modelDbSymbol = Symbol('mongoose#Model#db');
7675
const modelSymbol = require('./helpers/symbols').modelSymbol;
@@ -4882,7 +4881,11 @@ Model.compile = function compile(name, schema, collectionName, connection, base)
48824881
};
48834882

48844883
Model.clientEncryption = function clientEncryption() {
4885-
/** @type(import('mongodb').MongoClient) */
4884+
const ClientEncryption = driver.get().ClientEncryption;
4885+
if (!ClientEncryption) {
4886+
throw new Error('The mongodb driver must be used to obtain a ClientEncryption object.');
4887+
}
4888+
48864889
const client = this.collection?.conn?.client;
48874890

48884891
if (!client) return null;

scripts/configure-cluster-with-encryption.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ if [ ! -d "data" ]; then
4949
echo 'Configuring Cluster...'
5050

5151
# start cluster
52-
(bash $DRIVERS_TOOLS/.evergreen/run-orchestration.sh) 1>/dev/null 2>/dev/null
52+
(bash $DRIVERS_TOOLS/.evergreen/run-orchestration.sh)
5353

5454
echo 'Cluster Configuration Finished!'
5555

0 commit comments

Comments
 (0)