Reputation: 11712
I have a mySQL database table t1 with a bigint field called filter which I need to 'and' to a given query parameter in order to filter out entries.
table t1:
filter bigint unsigned
info varchar(200)
As a pure mySQL statement my query would be this:
SELECT info FROM t1 WHERE (filter & 34603933) = filter;
Of course the number 34603933
is a parameter and changes from query to query.
The question is, if loopbackjs supports such a calculus in the where condition. Can someone point me the way, or if it is not possible suggest a workaround?
In the documentation http://docs.strongloop.com/display/public/LB/Where+filter I did not see a possibility to do this, but somehow I can't really believe it, since using references to columns values in the right side of a where comparison is nothing unusual, right?
Upvotes: 1
Views: 124
Reputation: 3396
I do not believe loopback has this support built-in and bitwise and operations are not that widespread (in my experience). You might try the raw SQL interface:
var mysqlDS = app.dataSources.mysqlDS;
var bitWiseAndValue = 34603933;
mysqlDS.connector.query('SELECT info FROM t1 WHERE (filter & '+bitWiseAndValue+') = filter', function(err) {
if (err) {return console.log(err);}
// success actions
});
Upvotes: 1