How can I fetch all the collection names in a MongoDB Atlas database using Realm functions?

Viewed 24

I have gone through the official Atlas documentation but couldn't find this. Although in the MongoDB manual documentation I came across db.getCollectionNames() but it is also not working for me.

I am getting this error,

TypeError: 'getCollectionNames' is not a function

Please check out the following function and suggest me how I can get the desired result.

exports = function () {
  let collections = context.services.get("mongodb-atlas").db("messages").getCollectionNames();
  return collections;
};
0 Answers
Related