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

list databases #9048

Closed
its-dibo opened this issue May 23, 2020 · 2 comments
Closed

list databases #9048

its-dibo opened this issue May 23, 2020 · 2 comments
Labels
new feature This change adds new functionality, like a new method or class
Milestone

Comments

@its-dibo
Copy link

I am trying to list all databases useing mongodb and mongoose.
with mongodb it successesed, but with mogoose I got an error.

mongoose.connect(uri).then( connection=>{
    let Admin = mongoose.mongo.Admin;
    let admin = new Admin(connection.db);
    console.log({ admin });  //s: { db: undefined, topology: undefined, promiseLibrary: undefined }
    console.log({ dbs: admin.listDatabases() });
})

but I got the following error:

Cannot read property 's' of undefined

I'm using the last version of mongoose.

@its-dibo
Copy link
Author

solved by using:

let admin = new Admin(connection.connections[0].db);

@amankriet
Copy link

amankriet commented Mar 30, 2024

After trying the above method, I am getting a different error now -

return (0, execute_operation_1.executeOperation)(this.s.db.client, new list_databases_1.ListDatabasesOperation(this.s.db, options));
                                                                   ^

TypeError: Cannot read properties of undefined (reading 'client')

@vkarpov15 vkarpov15 reopened this Apr 4, 2024
@vkarpov15 vkarpov15 added this to the 8.4 milestone Apr 4, 2024
@vkarpov15 vkarpov15 added the new feature This change adds new functionality, like a new method or class label Apr 4, 2024
vkarpov15 added a commit that referenced this issue Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature This change adds new functionality, like a new method or class
Projects
None yet
Development

No branches or pull requests

3 participants