I am using boss_db
with erlang
and chicagoboss
. AFAIK, we should always try to use minimum number of database queries.
Right now, I'm making two separate queries for a single 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}).
Try lists:filter()
ActiveLegalUserList = lists:filter(fun(User) ->
User:legal() == true end,
ActiveUserList).