[mongoose] Added connection options related to auto encryption using CSFLE (#43723)

* added new connection options related to the new feature csfle

* added basic test case for auto-encryption in mongoose client connection
This commit is contained in:
Cledson
2020-04-08 13:08:16 -07:00
committed by GitHub
parent f00facd841
commit 5dbf929af4
2 changed files with 26 additions and 0 deletions
+10
View File
@@ -37,6 +37,7 @@
// Dongjun Lee <https://github.com/ChazEpps>
// Valentin Agachi <https://github.com/avaly>
// Jan Nemcik <https://github.com/JanNemcik>
// Cl3dson <https://github.com/cl3dson>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
@@ -395,6 +396,15 @@ declare module "mongoose" {
* is set to true.(default: false) */
autoCreate?: boolean;
/** Configure csfle as especified in MongoDB official guide */
autoEncryption?: {
keyVaultNamespace: string,
kmsProviders: any,
schemaMap: any,
extraOptions?: any
}
/** Specify a journal write concern (default: false). */
journal?: boolean;
+16
View File
@@ -37,6 +37,22 @@ const connection3 = mongoose.connect(connectUri, function (error) {
error.stack;
});
/**
* Test taken from MongoDB CSFLE guide
* https://docs.mongodb.com/drivers/use-cases/client-side-field-level-encryption-guide
*/
const connection4:Promise<mongoose.Mongoose> = mongoose.connect(connectUri,{
useNewUrlParser: true,
useUnifiedTopology: true,
autoEncryption: {
keyVaultNamespace: 'encryption.__keyVault',
kmsProviders: {},
schemaMap: {},
extraOptions: {}
}
})
var mongooseConnection: mongoose.Connection = mongoose.createConnection();
mongooseConnection.dropDatabase().then(()=>{});
mongooseConnection.dropCollection('foo').then(()=>{});