Model extra attributes
People.query.left_join("identification_documents"){
peoples.id == identification_documents.person_id
}.select(
"people.*",
"identification_documents.type AS doc_type",
"identification_documents.number AS doc_number"
).each(fetch_columns: true) do |x|
puts "Person #{x.full_name}: " +
"#{x.attributes["doc_type"]} - #{x.attributes["doc_number"]}"
endcustomers = Customer.query
.join("shippings"){ shippings.customer_id == customer.id }
.select("customers.*", "COUNT(shippings.*) as shipping_count")
customers.each(fetch_columns: true) do |x|
puts "customer #{x.id} => #{x.attributes["shipping_count"]}"
endLast updated