@@ -37,8 +37,7 @@ const ILLEGAL_COMMAND_FIELDS = new Set([
3737 'bsonRegExp' ,
3838 'serializeFunctions' ,
3939 'ignoreUndefined' ,
40- 'enableUtf8Validation' ,
41- 'isEncryptedCollection'
40+ 'enableUtf8Validation'
4241] ) ;
4342
4443/** @public
@@ -104,9 +103,6 @@ export interface CreateCollectionOptions extends CommandOperationOptions {
104103 * change streams that listen on this collection.
105104 */
106105 changeStreamPreAndPostImages ?: { enabled : boolean } ;
107-
108- /** @internal */
109- isEncryptedCollection ?: boolean ;
110106}
111107
112108/* @internal */
@@ -136,19 +132,6 @@ export class CreateCollectionOperation extends CommandOperation<Collection> {
136132 session : ClientSession | undefined ,
137133 timeoutContext : TimeoutContext
138134 ) : 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-
152135 const db = this . db ;
153136 const name = this . name ;
154137 const options = this . options ;
@@ -183,17 +166,37 @@ export async function createCollections<TSchema extends Document>(
183166 db . client . s . options . autoEncryption ?. encryptedFieldsMap ?. [ `${ db . databaseName } .${ name } ` ] ;
184167
185168 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+
186190 // Create auxilliary collections for queryable encryption support.
187191 const escCollection = encryptedFields . escCollection ?? `enxcol_.${ name } .esc` ;
188192 const ecocCollection = encryptedFields . ecocCollection ?? `enxcol_.${ name } .ecoc` ;
189193
190194 for ( const collectionName of [ escCollection , ecocCollection ] ) {
191- const createOp = new CreateCollectionOperation ( db , collectionName , {
195+ const createOp = new CreateSupportingFLEv2CollectionOperation ( db , collectionName , {
192196 clusteredIndex : {
193197 key : { _id : 1 } ,
194198 unique : true
195199 } ,
196- isEncryptedCollection : true ,
197200 session : options . session
198201 } ) ;
199202 await executeOperation ( db . client , createOp , timeoutContext ) ;
0 commit comments