1

In the following code snippet i am fetching all records from Installation of multiple userIds using inq operator of loopback. Code is working fine on local server but not on Heroku, it is returning empty result while record is available in collection.

module.exports = function(Installation) {
    Installation.getDeviceToken = function(userIds, callback) {
        if(!Array.isArray(userIds)) {
            var userIds = new Array(userIds);
        }
        console.log(userIds);
        Installation.find({
            where: { 
                userId: {inq: userIds} 
            },
            scope: {
              fields: {deviceToken: true}
            }
        }).then(function(result){
            var deviceTokens = [];
            console.log(result);
            var stringifiedTokens = JSON.stringify(result);
            var tokensObject = JSON.parse(stringifiedTokens);
            tokensObject.forEach(function(token) {
                deviceTokens.push(token.deviceToken);
            });
            callback(null, deviceTokens);
        }).catch(function(err){
            console.log(err);
        });
    };
};
  • Maybe a datasource configuration issue? Hard to tell without seeing your config files, but this may be related: http://stackoverflow.com/questions/21651567/how-to-configure-strongloop-loopback-mongodb-datasource-for-deployment-to-heroku?rq=1 – amuramoto May 19 '16 at 14:14
  • 1
    @amuramoto, actually other queries are working fine for example it give result if i run **Installation.find({ where { userid:id } })** for single record. Only problem is with **inq** operator on Heroku server. – Shakeel Ahmad May 19 '16 at 14:47
  • I have the same problem using postgres connector on amazon web services. – rm8x May 20 '16 at 14:39

0 Answers0