<     May 2017     >
Su Mo Tu We Th Fr Sa  
    1  2  3  4  5  6  
 7  8  9 10 11 12 13  
14 15 16 17 18 19 20  
21 22 23 24 25 26 27  
28 29 30 31
00:45 <eydaimon> is Evans on vacation? :P
01:11 <adam12> eydaimon: not that I know of :)
03:56 glennpratt joined
04:37 glennpratt joined
11:33 pdrakeweb joined
12:16 nirvdrum joined
16:23 marahin joined
16:23 <marahin> Hello!
16:24 <marahin> I'm using Sequel in my application. I used ActiveRecord so far only, so this is a huge journey :) for me. My question is: I have a Guild model, GuildMembership model and Players model. I want to access `Guild.last.members`, and that to return all players who are in the membership table with given guild_id.
16:24 <marahin> https://dropbox.gimb.us/b/4a3c1e026d65ce3c0c096134bb0dad6e.png
16:25 <marahin> This is Guild Membership database structure.
16:25 <marahin> The question is: how do I do that in Sequel?
16:25 <marahin> in AR I would use something like has_many through: ..., or something like that.
17:02 <onewheelskyward> marahin you probably don't even need through.
17:02 <marahin> onewheelskyward I think I just managed to get it working
17:03 <onewheelskyward> guild.players?
17:03 <marahin> one_through_one :guild, join_table: :guild_membership, left_key: :player_id, left_primary_key: :id, right_key: :guild_id
17:03 <marahin> onewheelskyward ^ character.guild
17:03 <marahin> :)
17:03 <onewheelskyward> aah gotchya
17:03 <onewheelskyward> oh so that image you sent was the guild memberships table?
17:03 <marahin> yes!
17:03 <marahin> at least i think so haha
17:03 <marahin> yeah, it was memberships
17:03 <onewheelskyward> Makes sense. :)
17:04 <marahin> sorry, I thought I managed to capture the table name as well.
19:35 <marahin> Another question: if I have a Guild model that has Members, how can I order by members count? Assuming there's a relation N members -> 1 guild.
19:35 <marahin> There's no counter cache (or anything that would be equal to it in Sequel)
19:38 <marahin> Would something like Guild.join_table(:inner, :guild_membership, :guild_id).order(Sequel.desc("COUNT(*) FROM guild_memberships")) work? It generates:
19:38 <marahin> => #<Sequel::Mysql2::Dataset: "SELECT * FROM `guilds` INNER JOIN `guild_membership` ON `guild_id` ORDER BY 'COUNT(*) FROM guild_memberships' DESC">
20:25 aidalgol joined
21:08 glennpratt joined
21:33 glennpratt joined
21:58 glennpratt joined
23:58 pdrakeweb joined