Module: Filemaker::Api::QueryCommands

Defined in:
lib/filemaker/api.rb,
lib/filemaker/api/query_commands/dup.rb,
lib/filemaker/api/query_commands/new.rb,
lib/filemaker/api/query_commands/edit.rb,
lib/filemaker/api/query_commands/find.rb,
lib/filemaker/api/query_commands/view.rb,
lib/filemaker/api/query_commands/delete.rb,
lib/filemaker/api/query_commands/findall.rb,
lib/filemaker/api/query_commands/findany.rb,
lib/filemaker/api/query_commands/findquery.rb

Defined Under Namespace

Classes: CompoundFind

Instance Method Summary collapse

Instance Method Details

#delete(id, options = {}) ⇒ Object

Delete record.

-recid -script -script.param



10
11
12
13
# File 'lib/filemaker/api/query_commands/delete.rb', line 10

def delete(id, options = {})
  valid_options(options, :script)
  perform_request('-delete', { '-recid' => id }, options)
end

#dup(id, options = {}) ⇒ Object

Duplicate record.

-recid -script -script.param -relatedsets.filter -relatedsets.max



12
13
14
15
16
17
18
19
# File 'lib/filemaker/api/query_commands/dup.rb', line 12

def dup(id, options = {})
  valid_options(options,
                :script,
                :relatedsets_filter,
                :relatedsets_max)

  perform_request('-dup', { '-recid' => id }, options)
end

#edit(id, values, options = {}) ⇒ Object

Edit record.

-recid -modid -script -script.param -relatedsets.filter -relatedsets.max -delete.related



14
15
16
17
18
19
20
21
22
23
# File 'lib/filemaker/api/query_commands/edit.rb', line 14

def edit(id, values, options = {})
  valid_options(options,
                :modid,
                :script,
                :relatedsets_filter,
                :relatedsets_max,
                :delete_related)

  perform_request('-edit', { '-recid' => id }.merge(values), options)
end

#find(id_or_hash, options = {}) ⇒ Object

Find record(s).

-max -skip -sortfield. -sortorder. -fieldname -fieldname.op -lop -recid -lay.response -script -script.param -script.prefind -script.prefind.param -script.presort -script.presort.param -relatedsets.filter -relatedsets.max



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/filemaker/api/query_commands/find.rb', line 24

def find(id_or_hash, options = {})
  valid_options(options,
                :max,
                :skip,
                :sortfield,
                :sortorder,
                :lop,
                :lay_response,
                :script,
                :script_prefind,
                :script_presort,
                :relatedsets_filter,
                :relatedsets_max)

  if id_or_hash.is_a? Hash
    perform_request('-find', id_or_hash, options)
  else
    perform_request('-find', { '-recid' => id_or_hash }, options)
  end
end

#findall(options = {}) ⇒ Object

Find all records. Sorting may be slow for huge records.

Acceptable params are: -max -skip -sortfield. -sortorder. -script -script.param -script.prefind -script.prefind.param -script.presort -script.presort.param -relatedsets.filter



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/filemaker/api/query_commands/findall.rb', line 20

def findall(options = {})
  valid_options(options,
                :max,
                :skip,
                :sortfield,
                :sortorder,
                :script,
                :script_prefind,
                :relatedsets_filter)

  perform_request('-findall', {}, options)
end

#findany(options = {}) ⇒ Object

Find a random record.

If data cannot be coerced, it will crash! Acceptable params are: -script -script.param -script.prefind -script.prefind.param -relatedsets.filter -relatedsets.max



15
16
17
18
19
20
21
22
23
# File 'lib/filemaker/api/query_commands/findany.rb', line 15

def findany(options = {})
  valid_options(options,
                :script,
                :script_prefind,
                :relatedsets_filter,
                :relatedsets_max)

  perform_request('-findany', {}, options)
end

#findquery(query_hash, options = {}) ⇒ Object

Raw -findquery if you want to construct your own.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/filemaker/api/query_commands/findquery.rb', line 20

def findquery(query_hash, options = {})
  valid_options(options,
                :max,
                :skip,
                :sortfield,
                :sortorder,
                :lay_response,
                :script,
                :script_prefind,
                :script_presort,
                :relatedsets_filter,
                :relatedsets_max)

  perform_request('-findquery', query_hash, options)
end

#new(values, options = {}) ⇒ Object

Add new record.

-script -script.param -relatedsets.filter -relatedsets.max



11
12
13
14
15
16
17
18
# File 'lib/filemaker/api/query_commands/new.rb', line 11

def new(values, options = {})
  valid_options(options,
                :script,
                :relatedsets_filter,
                :relatedsets_max)

  perform_request('-new', values, options)
end

#query(array_hash, options = {}) ⇒ Object

Find records using compound find query command.

query(status: ‘open’, title: ‘web’) => (q0,q1) query(status: %w(open closed)) => (q0);(q1)



9
10
11
12
13
14
15
16
17
# File 'lib/filemaker/api/query_commands/findquery.rb', line 9

def query(array_hash, options = {})
  compound_find = CompoundFind.new(array_hash)

  query_hash = compound_find.key_values.merge(
    '-query' => compound_find.key_maps_string
  )

  findquery(query_hash, options)
end

#viewObject

Retrieves <metadata> section of XML.



6
7
8
# File 'lib/filemaker/api/query_commands/view.rb', line 6

def view
  perform_request('-view', {}, {})
end