GhMartingit / xk6-mongo

Apache License 2.0
7 stars 25 forks source link

Add NewClientWithOptions method for passing custom ClientOptions to the mongo connection #30

Open jorgelc opened 3 months ago

jorgelc commented 3 months ago

Implementation of an additional method which passes a ClientOptions object to the mongo client.

This allows further customization of the client options.

This snipped shows how the new method is called.

const mongoUri = `mongodb://mongo-user:mongo-password@127.0.0.1:27017/admin?connect=direct`
const clientOptions = {
    "app_name": "MyApp", 
    //...
    "server_api_options": { 
        "server_api_version": "1",
        "strict": true 
    }
    //...
};
const client = xk6_mongo.newClientWithOptions(mongoUri, clientOptions)