I want to dynamically call different database collections in my app based on a string like below:
const collection = 'books';
db.${collection}.find() // turns into db.books.find()
I am using ES6, so if there are any easy ways to do this that would be great! I've been unable to find the way to create this.
EDIT: I am not trying to access part of a object, but anywhere. I'd also want to do something like
${collection}.db.find()