I'm trying to make the connection with MongoDB database but I can't to export database object, inestead export a promise.
What I would be missing?
index.js
export const db = async() => {
return await MongoClient.connect(MONGO_URL)
}
I have also tried this way:
export const db = async() => {
const result = await MongoClient.connect(MONGO_URL)
return result
}
resolvers.js
import { db } from '/mongodb'
This function returns Async Function db