I know there are other questions here asking about the same error, but I couldn't find one specific to my situation.
I try to connect with mongo database:
var dbConn = MongoClient.connect('mongodb://localhost', function (err, client) {
if (err) throw err;
var db = client.db('mytestingdb');
});
and I get an error on this part of the code:
app.post('/thanks', function(req, res) {
if (atendees.checkin === req.body.dbstring) {
dbConn.then(function(db) { //error here
delete req.body._id;
db.collection('feedbacks').insertOne(req.body);
})
res.redirect('/thanks.html')
}
(...)
The idea is to send a form to a database
I tried to follow this tutorial here:
https://programmingmentor.com/post/save-form-nodejs-mongodb/
But the way he tries to connect to the server:
var dbConn = mongodb.MongoClient.connect('mongodb://localhost:27017');
Also gives me an error (db.collection is not a function). From what I've seen here in StackOverflow, that's because of my version of Mongodb. But how can I translate this to the newer version?