ErlyORM / boss_db

BossDB: a sharded, caching, pooling, evented ORM for Erlang
Other
277 stars 138 forks source link

Is it possible to filter query results? #222

Closed laxmikantG closed 9 years ago

laxmikantG commented 9 years ago

I am using boss_db with erlang and chicagoboss. Right now, I'm making two separate queries for a result. Which I assume can be done in one query but don't know how.

Query1

ActiveUserList = boss_db:find(user,
                             [{status, 'equals', active},{cid, 'equals', Cid}]).

Query2

ActiveLegalUserList = boss_db:find(user, 
     [{status, 'equals', active},{cid, 'equals', Cid},{legal, 'equals', true}]).

Is there any way to achieve this in one query? like:

ActiveLegalUserList = ActiveUserList:filter({legal, 'equals', true}).
danikp commented 9 years ago

you can use lists:filter to filter query results

davidw commented 9 years ago

I just use SQL when queries are more complex - find_by_sql for instance.

danikp commented 9 years ago

@davidw, that not our case, cause you doing two queries anyway.

laxmikantG commented 9 years ago

@danikp @davidw
Thanks for your suggestions. lists:filter worked for me. But still I would expect that as a feature. Thnk you