Data relation constraints part of database query

Instead of the constrains being simple field, value pairs, they can be any valid mongo query specifier (such as {'bar': {'$gt': 10}}) as they are now used as part of database query.