Method: FastAPI#safe_filter

Defined in:
lib/fastapi.rb

#safe_filter(filters = {}, meta = {}) ⇒ FastAPI

Create and execute an optimized SQL query based on specified filters.

Runs through mode fastapi_safe_fields list

Parameters:

  • filters (Hash) (defaults to: {})

    a hash containing the intended filters

  • meta (Hash) (defaults to: {})

    a hash containing custom metadata

Returns:

  • (FastAPI)

    the current instance



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/fastapi.rb', line 74

def safe_filter(filters = {}, meta = {})

  result = fastapi_query(filters, true)

   = {}

  meta.each do |key, value|
    [key] = value
  end

  [:total] = result[:total]
  [:offset] = result[:offset]
  [:count] = result[:count]
  [:error] = result[:error]

  @metadata = 
  @data = result[:data]

  @result_type = @@result_types[:multiple]

  self

end