@@ -37,8 +37,7 @@ const ILLEGAL_COMMAND_FIELDS = new Set([
37
37
'bsonRegExp' ,
38
38
'serializeFunctions' ,
39
39
'ignoreUndefined' ,
40
- 'enableUtf8Validation' ,
41
- 'isEncryptedCollection'
40
+ 'enableUtf8Validation'
42
41
] ) ;
43
42
44
43
/** @public
@@ -104,9 +103,6 @@ export interface CreateCollectionOptions extends CommandOperationOptions {
104
103
* change streams that listen on this collection.
105
104
*/
106
105
changeStreamPreAndPostImages ?: { enabled : boolean } ;
107
-
108
- /** @internal */
109
- isEncryptedCollection ?: boolean ;
110
106
}
111
107
112
108
/* @internal */
@@ -136,19 +132,6 @@ export class CreateCollectionOperation extends CommandOperation<Collection> {
136
132
session : ClientSession | undefined ,
137
133
timeoutContext : TimeoutContext
138
134
) : Promise < Collection > {
139
- if ( this . options . isEncryptedCollection ) {
140
- // Creating a QE collection required min server of 7.0.0
141
- // TODO(NODE-5353): Get wire version information from connection.
142
- if (
143
- ! server . loadBalanced &&
144
- server . description . maxWireVersion < MIN_SUPPORTED_QE_WIRE_VERSION
145
- ) {
146
- throw new MongoCompatibilityError (
147
- `${ INVALID_QE_VERSION } The minimum server version required is ${ MIN_SUPPORTED_QE_SERVER_VERSION } `
148
- ) ;
149
- }
150
- }
151
-
152
135
const db = this . db ;
153
136
const name = this . name ;
154
137
const options = this . options ;
@@ -183,17 +166,37 @@ export async function createCollections<TSchema extends Document>(
183
166
db . client . s . options . autoEncryption ?. encryptedFieldsMap ?. [ `${ db . databaseName } .${ name } ` ] ;
184
167
185
168
if ( encryptedFields ) {
169
+ class CreateSupportingFLEv2CollectionOperation extends CreateCollectionOperation {
170
+ override execute (
171
+ server : Server ,
172
+ session : ClientSession | undefined ,
173
+ timeoutContext : TimeoutContext
174
+ ) : Promise < Collection > {
175
+ // Creating a QE collection required min server of 7.0.0
176
+ // TODO(NODE-5353): Get wire version information from connection.
177
+ if (
178
+ ! server . loadBalanced &&
179
+ server . description . maxWireVersion < MIN_SUPPORTED_QE_WIRE_VERSION
180
+ ) {
181
+ throw new MongoCompatibilityError (
182
+ `${ INVALID_QE_VERSION } The minimum server version required is ${ MIN_SUPPORTED_QE_SERVER_VERSION } `
183
+ ) ;
184
+ }
185
+
186
+ return super . execute ( server , session , timeoutContext ) ;
187
+ }
188
+ }
189
+
186
190
// Create auxilliary collections for queryable encryption support.
187
191
const escCollection = encryptedFields . escCollection ?? `enxcol_.${ name } .esc` ;
188
192
const ecocCollection = encryptedFields . ecocCollection ?? `enxcol_.${ name } .ecoc` ;
189
193
190
194
for ( const collectionName of [ escCollection , ecocCollection ] ) {
191
- const createOp = new CreateCollectionOperation ( db , collectionName , {
195
+ const createOp = new CreateSupportingFLEv2CollectionOperation ( db , collectionName , {
192
196
clusteredIndex : {
193
197
key : { _id : 1 } ,
194
198
unique : true
195
199
} ,
196
- isEncryptedCollection : true ,
197
200
session : options . session
198
201
} ) ;
199
202
await executeOperation ( db . client , createOp , timeoutContext ) ;
0 commit comments