Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('CliServiceProvider [integration]', function() {
describe('.getConnectionInfo', () => {
context('when a uri has been passed', () => {
it('returns the connection\'s info', async() => {
const instance = new CliServiceProvider(client, connectionString);
const instance = new CliServiceProvider(client, {}, new ConnectionString(connectionString));
const connectionInfo = await instance.getConnectionInfo();

expect(Object.keys(connectionInfo)).to.deep.equal([
Expand Down
7 changes: 3 additions & 4 deletions packages/service-provider-server/src/cli-service-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ class CliServiceProvider extends ServiceProviderCore implements ServiceProvider
* MongoClient instance.
*
* @param {MongoClient} mongoClient - The Node drivers' MongoClient instance.
* @param clientOptions
* @param {MongoClientOptions} clientOptions
* @param {string} uri - optional URI for telemetry.
*/
constructor(mongoClient: MongoClient, clientOptions = {}, uri?: ConnectionString) {
constructor(mongoClient: MongoClient, clientOptions: MongoClientOptions = {}, uri?: ConnectionString) {
super(bsonlib);
this.mongoClient = mongoClient;
this.uri = uri;
Expand All @@ -222,12 +222,11 @@ class CliServiceProvider extends ServiceProviderCore implements ServiceProvider
async getNewConnection(uri: string, options: MongoClientOptions = {}): Promise<CliServiceProvider> {
const connectionString = new ConnectionString(uri);
const clientOptions = processDriverOptions(options);

const mongoClient = await connectMongoClient(
connectionString.toString(),
clientOptions
);
return new CliServiceProvider(mongoClient, connectionString);
return new CliServiceProvider(mongoClient, clientOptions, connectionString);
}

async getConnectionInfo(): Promise<ConnectionInfo> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import CliServiceProvider from '../cli-service-provider';
import { MongoClient } from 'mongodb';
import { DEFAULT_DB, ReplPlatform } from '@mongosh/service-provider-core';
import { MongoClient, MongoClientOptions } from 'mongodb';
import { ConnectionString, ReplPlatform } from '@mongosh/service-provider-core';

interface DataService {
client: {
Expand All @@ -13,22 +13,21 @@ interface DataService {
*/
class CompassServiceProvider extends CliServiceProvider {
public readonly platform: ReplPlatform;
public readonly initialDb: string;
/**
* Instantiate a new CompassServiceProvider with the data-service's connected
* MongoClient instance.
*
* @param {MongoClient} mongoClient - The Node drivers' MongoClient instance.
* @param {MongoClientOptions} driverOptions
* @param {string} uri - optional URI for telemetry.
*/
constructor(mongoClient: MongoClient, uri?: string) {
super(mongoClient, uri);
constructor(
mongoClient: MongoClient,
driverOptions: MongoClientOptions = {},
uri?: ConnectionString
) {
super(mongoClient, driverOptions, uri);
this.platform = ReplPlatform.Compass;
try {
this.initialDb = (mongoClient as any).s.options.dbName || DEFAULT_DB;
} catch (err) {
this.initialDb = DEFAULT_DB;
}
}
/**
* Creates a new CompassServiceProvider that uses compass
Expand Down