On Sat, Nov 18, 2023 at 10:52 PM [email protected] <[email protected]>
wrote:

> lets say you have:
>
> class User
>   one_to_one :best_purchase, class: :Purchase
> end
> class Purchase
>   many_to_one :product
> end
> class Product
>   # has column :tier which is a number.
> end
>
> I want to do something like
>
> class User
>   one_to_one :best_purchase,
>     class: :Purchase,
>     order: Sequel.desc(Sequel[:product][:tier]),
>     add_join :product
> end
>
> Is there a way to do this?
>

I haven't tried this, but you can try an association block:

  one_to_one :best_purchase,
    class: :Purchase,
    order: Sequel.desc(Sequel[:product][:tier]) do |ds|
      ds.association_join(:product)
    end

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/CADGZSSdKT6g6RvYwxoAAzeKxMCUPjebRpfrwjdfMoJ02L%3D_wYQ%40mail.gmail.com.

Reply via email to