-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Find a better way to rewrite how the Mongoid::Identity mixin yields conditions #47
Labels
Comments
This is actually a bigger deal. If you throw a sort in there, you no longer hit an index. The $sort throws it off. Without Sort
With Sort
Ouch. |
dblock
added a commit
to dblock/garner
that referenced
this issue
Jul 11, 2013
fancyremarker
pushed a commit
that referenced
this issue
Jul 11, 2013
Fixed #47: use a database index when generating proxy binding in Garner::Mixins::Mongoid::Identity with multiple Garner.config.mongoid_identity_fields.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We set
Garner.config.mongoid_identity_fields = [:_id, :_slugs]
. In our case, these are two separate ways to find an instance of a Model that are mutually exclusive and follow distinct formats.Garner's
Garner::Mixins::Mongoid::Identity
will combine these into an$or
. Here're two possible queries:This is not very efficient and we can make the decision about whether the query is done by slug or by id upfront, so we monkey patch this as follows.
This is very much custom. But maybe there's a better way to describe this in Garner without writing a completely different mixin?
The text was updated successfully, but these errors were encountered: