Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have idea for support multiple collection. #1

Open
renogies opened this issue Oct 22, 2024 · 0 comments
Open

I have idea for support multiple collection. #1

renogies opened this issue Oct 22, 2024 · 0 comments

Comments

@renogies
Copy link

renogies commented Oct 22, 2024

class MongoConnection {
private env: any;

constructor(env: any) {
    this.env = env;
}
// Generic method to return a collection of a specific type
collection<T>(): MongoDBAPI<T> {
    return new MongoDBAPI<T>(this.env);
}

}


// Create a MongoConnection instance
const connection = new MongoConnection(env);

// Get the collections
const taskCollection = connection.collection();
const taskItemCollection = connection.collection();

const task = await taskCollection.findOne({ status: { $eq: "complete" } });
console.log("Found task:", task);

const taskItem = await taskItemCollection.findOne({ status: { $eq: "complete" } });
console.log("Found taskItem :", taskItem );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant