Returning model instances for raw sql using Ruby Sequel

Is there a way to return Sequel return models instead of a hash for raw sql?

class Post < Sequel::Model def self.recent db["some sql goes here"].all #would like models returned here instead end end 

Hope this makes sense.

+4
source share
1 answer
 class Post < Sequel::Model def self.recent with_sql("some sql goes here").all end end 
+6
source

Source: https://habr.com/ru/post/1447626/


All Articles