[best pratices] virtual resources

13 views
Skip to first unread message

antonio altamura

unread,
Mar 26, 2016, 3:03:24 PM3/26/16
to nodejs
Hi, I'm developing a MEAN app. I'm wondering if I made a good choice for this:
I deleted my mongodb collection "presidents" and I exposed this express resource in this way


router.get('/', function(req,res) {
    var presidents=["President","Vice-President","Grand President",...];
    var query = regexp.startsWith(req.query.q)
    var ret= []
    presidents.forEach(function (el) {
        if (query.test(el)) ret.push(el)
    });
    return res.json(ret)
});

So no more extra mongodb collection for this. Obiouvsly the presidents in my case can't change, I use this array  just for an autocomplete text field.
Do you think it's a good pratice make those 'immutable' collection like this?

Reply all
Reply to author
Forward
0 new messages