I have two collections like follwoing,
customers:
{id: 1, name: "foo"}
{id: 2, name: "bar"}
{id: 3, name: "baz"}
flags:
{cid: 1}
{cid: 3}
Then retrieving customers whose flag is on
db.customers.find({id: {$in: db.flags.distinct("cid", {})}})
On shell this works, but I can't do the same using casbah, since casbah does not seem to support querying with function call or local variable.