Tuesday, 11 July 2017

Having trouble with case insensitive queries with Express + Mongodb

I migrated a website to a new server, and I have no idea why some of my routes are crashing. This for example now on the new servers says that "docs" are undefined.when I remove the collation part from the query, it works...but it doesnt return any docs (runs my else statement) since I need the case sensitive parameters via the "strength: 2" part.Any idea on how to troubleshoot this? It works just fine on my dev server but maybe on my new server I have a different version for some package.router.get('/blog/list/:name', auth, function(req, res) { var db = req.db; blogName = req.params.name; blogName = blogName.replace(/-/g, ' '); var collection = db.collection('blog'); collection.find({ "name": blogName }).collation({ locale: 'en', strength: 2 }).toArray(function(err, docs) { if (docs.length > 0) { res.render('blog', { "bloglist": docs }); } else { res.send('page not found...') } }); });

Submitted July 11, 2017 at 07:14AM by InsertCoinPushStart

No comments:

Post a Comment