Hello everyone, I'm facing an issue with getting MongoDB to work in my Angular 4 project. In my code, I have the db
object as a client of the MongoClient
class:
MongoClient.connect('mongodb://localhost:27017/test', (err, client) => {
// Client returned
var db = client.db('test');});
However, when I try to use db.collection()
, I encounter this error:
let db = DbClient.connect();
db.collection();
In my app.module.ts
file, I receive the following error message:
"[ts] Property 'collection' does not exist on type 'void'."
The project uses Node.js version 8.10.0, MongoDB version 2.2.33, and @type/mongodb version 3.0.9. I even tried downgrading to version 3.0.5 after searching for a solution, but unfortunately it's still not working. Can anyone offer assistance in resolving this error?