Class: ActiveRecord::Embedded::Aggregation::Postgresql

Inherits:
Native show all
Defined in:
lib/active_record/embedded/aggregation/postgresql.rb

Overview

Driver for JSON/JSONB query support in PostgreSQL. Uses a @> query to look for partial JSON in the data Array.

Instance Method Summary collapse

Methods inherited from Native

#query_for

Methods inherited from ActiveRecord::Embedded::Aggregation

create, #each, find, #initialize, #inspect

Methods included from Query

#build, #create, #create!, #find, #find!, #find_by, #find_by!, #initialize, #order, #where

Constructor Details

This class inherits a constructor from ActiveRecord::Embedded::Aggregation

Instance Method Details

#resultsObject


11
12
13
14
# File 'lib/active_record/embedded/aggregation/postgresql.rb', line 11

def results
  parent.where("#{as} @> ?", params)
        .map { |record| [record, query_for(record)] }
end