Hi everyone, I have nexjs project where I use mongoClient to connect MongoDB, I want to take databases names and their collections names together as an object, I mean something like this, for example:
[
{database: “test”, collections: [“users”, “posts”, “jobs”]}
{database: “test1”, collections: [“users1”, “posts1”, “jobs1”]}
]
I get databases names and collections names but separately, and I can’t understand how can I push the database with the appropriate collections in an array.
Thanks for your attention!
this code is here, may you will understand better what I want to do
I notice you haven’t had a response to this topic yet, were you able to solution?
If not, below is an example code giving out database and collections names similar to your requirements using javascript, you can integrate it with your code and test.
Hello, first of all, sorry for the late reply, I saw your answer yesterday but I could not verify and use the code, thank’s for your answer, this solution works for me