remi / her

Her is an ORM (Object Relational Mapper) that maps REST resources to Ruby objects. It is designed to build applications that are powered by a RESTful API instead of a database.
MIT License
2.05k stars 322 forks source link

Support for association extensions #522

Open noctivityinc opened 5 years ago

noctivityinc commented 5 years ago

Sorry for all the posts but I'm loving Her and just want to see it keep getting better.

I checked all the Issues and don't see this. Is there support for association extensions? For example:

class User
   has_many :addresses do 
     def count 
        # custom get that doesn't return all the records first and then add the array
     end
   end
end

so @user.addresses.count would use the defined count instead of doing what it appears now, which is:

  1. Hit the User endpoint
  2. If response includes addresses, return those, if not, hit the addresses endpoint
  3. return the count of the array
zacharywelch commented 5 years ago

Unfortunately no, but that would be a really cool feature that we'd love to see 😻There's a more fundamental problem with scopes on associations that will probably need to be resolved first.