🚀 The feature
I had to create this in order to use it in my application, because I have to set various options with the client:
import { MongoDb } from '@llm-tools/embedjs-mongodb';
import createDebugMessages from 'debug';
class ExtendedMongoDb extends MongoDb {
debug = createDebugMessages('embedjs:vector:ExtendedMongoDb');
constructor({ client, dbName, collectionName }) {
// Call parent constructor with dummy connection string
super({
connectionString: 'mongodb://placeholder',
dbName,
collectionName
});
// Override the client
this.client = client;
}
async init({ dimensions }) {
this.debug('Using existing database connection');
// Skip connection since we have a client
const database = this.client.db(this.dbName);
this.collection = database.collection(this.collectionName);
// Let parent class handle index creation
await super.init({ dimensions });
}
}
export default ExtendedMongoDb;
Motivation, pitch
Mongo has two options for creation, const client = new MongoClient(uri, options);
Allow the passing in of options
🚀 The feature
I had to create this in order to use it in my application, because I have to set various options with the client:
import { MongoDb } from '@llm-tools/embedjs-mongodb';
import createDebugMessages from 'debug';
class ExtendedMongoDb extends MongoDb {
debug = createDebugMessages('embedjs:vector:ExtendedMongoDb');
}
export default ExtendedMongoDb;
Motivation, pitch
Mongo has two options for creation, const client = new MongoClient(uri, options);
Allow the passing in of options