Closed jgaskins closed 10 years ago
In the case of any?
or none?
for mongodb, we should delegate them to ruby instead of the DB. Better this way that without those methods. It make sense?
The problem with doing it outside the database is that it we'd have to retrieve everything first, which wastes bandwidth, processor cycles and memory. It'll be much better if we can do them in the DB.
For example, here's what the mapper.select { |user| user.friends.any? }
query would look like in MongoDB:
db.User.find({ friends: { $ne: [] } })
For Postgres:
SELECT * FROM "User" WHERE json_array_length(friends) > 0`
Both of these should be easily doable from their respective adapters.
Closing. We have specs for any?
and none?
on query attributes and both are implemented in both the MongoDB and Postgres adapters.
One requested feature was adding Enumerable predicates to query attributes.
We could add integration specs to test for enumerable predicates on query attributes to make sure they're implemented in the database adapters (if possible).
I'll add separate issues in the Postgres and MongoDB adapter repos for DB-specific discussion, as well.