Method: Diplomat::Query#execute

Defined in:
lib/diplomat/query.rb

#execute(key, options = {}) ⇒ OpenStruct

Execute a prepared query or prepared query template rubocop:disable Metrics/PerceivedComplexity

Parameters:

  • key (String)

    the prepared query ID or name

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

    prepared query execution options

  • dc (Hash)

    a customizable set of options

  • near (Hash)

    a customizable set of options

  • limit (Hash)

    a customizable set of options

Returns:

  • (OpenStruct)

    the list of results from the prepared query or prepared query template



69
70
71
72
73
74
75
76
# File 'lib/diplomat/query.rb', line 69

def execute(key, options = {})
  custom_params = []
  custom_params << use_named_parameter('dc', options[:dc]) if options[:dc]
  custom_params << use_named_parameter('near', options[:near]) if options[:near]
  custom_params << use_named_parameter('limit', options[:limit]) if options[:limit]
  ret = send_get_request(@conn, ["/v1/query/#{key}/execute"], options, custom_params)
  OpenStruct.new JSON.parse(ret.body)
end