Method: Valkyrie::Persistence::Postgres::QueryService#find_members_with_type_query

Defined in:
lib/valkyrie/persistence/postgres/query_service.rb

#find_members_with_type_queryString

Note:

this uses a CROSS JOIN for all combinations of member IDs with the IDs of their parents

Generate the SQL query for retrieving member resources in PostgreSQL using a

resource ID and resource type as arguments.

This also uses JSON functions in order to retrieve JSON property values



165
166
167
168
169
170
171
172
173
# File 'lib/valkyrie/persistence/postgres/query_service.rb', line 165

def find_members_with_type_query
  <<-SQL
    SELECT member.* FROM orm_resources a,
    jsonb_array_elements(a.metadata->'member_ids') WITH ORDINALITY AS b(member, member_pos)
    JOIN orm_resources member ON (b.member->>'id')::#{id_type} = member.id WHERE a.id = ?
    AND member.internal_resource = ?
    ORDER BY b.member_pos
  SQL
end