Module: SfCli::Sf::Data::Query
- Defined in:
- lib/sf_cli/sf/data/query.rb,
lib/sf_cli/sf/data/query_helper.rb
Instance Method Summary collapse
-
#query(soql, target_org: nil, format: nil, bulk: false, wait: nil, api_version: nil, model_class: nil, &block) ⇒ Array, [String,Array]
Get object records using SOQL.
-
#query_resume(job_id:, target_org: nil, format: nil, api_version: nil, model_class: nil) ⇒ Array, [String,Array]
Resume a bulk query job, which you previously started, and get records.
Instance Method Details
#query(soql, target_org: nil, format: nil, bulk: false, wait: nil, api_version: nil, model_class: nil, &block) ⇒ Array, [String,Array]
Get object records using SOQL. When using Bulk API, you get the records when the query job completes within time limit. The method returns a tapple(an array), which changes its contents according to the job result.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/sf_cli/sf/data/query.rb', line 46 def query(soql, target_org: nil, format: nil, bulk: false, wait: nil, api_version: nil, model_class: nil, &block) flags = { :"query" => %("#{soql}"), :"target-org" => target_org, :"result-format" => format, :"wait" => (bulk ? wait : nil), :"api-version" => api_version, } switches = { bulk: bulk, } raw_output = format ? true : false redirect_type = raw_output ? nil : :null_stderr format = format&.to_sym || :json exec_result = exec(__method__, flags: flags, switches: switches, redirection: redirect_type, raw_output: raw_output, format: format) results = return_result(exec_result, raw_output, bulk, model_class) return results if raw_output results.each(&block) if block_given? results end |
#query_resume(job_id:, target_org: nil, format: nil, api_version: nil, model_class: nil) ⇒ Array, [String,Array]
Resume a bulk query job, which you previously started, and get records
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/sf_cli/sf/data/query.rb', line 97 def query_resume(job_id:, target_org: nil, format: nil, api_version: nil, model_class: nil) flags = { :"bulk-query-id" => job_id, :"target-org" => target_org, :"result-format" => format, :"api-version" => api_version, } raw_output = format ? true : false format = format || :json action = __method__.to_s.tr('_', ' ') result = exec(action, flags: flags, redirection: :null_stderr, raw_output: raw_output, format: format) return_result(result, raw_output, true, model_class) end |