-
Notifications
You must be signed in to change notification settings - Fork 376
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
How to filter an Association? #267
Comments
If you are using |
My intention is actually the reverse filter I set the hasOne, I thought the reverse applied a hasMany the user for email. You said I was supposed to use the hasMany, but I can use without having a join table? |
I have to think how to change the interface to allow a reverse hasOne to be a hasMany. There's currently no support for it, but this is on the top of my list. |
Maybe the phenomenon described in #281 has the same reason. The |
and #237 as well. Maybe it's very easy one: in interface, just makes reversed getAccessor return a ChainFind, so we can filter/count/limit, etc. on it. in theory, a hasOne is a 1-to-n relation, a table A has a B_id, it means table B may have many different A instance. so at the reversed case, it should be a n-to-1 relation. hopes to see this is implement :-) |
@starwing is right, a reversed hasOne should behave very similar to a normal hasMany. I'm hoping to fix this until the end of next week. Hopefully I'll also add more detail in the wiki about the differences in associations. |
@dresende I've started to run into this issue in a variety of places. Has there been any progress on this? |
It depends on the place. Do you have examples? |
We have models Like.hasOne( 'owner', User, {
reverse: 'likes'
}); I think I should be able to use: User.get( 1, function( err, user ){
user.getLikes().limit(5).run( function( err, likes ){
console.log( likes );
});
}); But I can't since the |
Returns a ChainFind which can then be filtered..
Please try this latest commit. |
I want to be able to filter a association, as in the example below only bring the emails assets of a particular user.
The text was updated successfully, but these errors were encountered: