Method: Sequel::Postgres::JSONBOp#path_query_first

Defined in:
lib/sequel/extensions/pg_json_ops.rb

#path_query_first(path, vars = nil, silent = nil) ⇒ Object

Returns the first item of the result specified by the JSON path for the json object.

json_op.path_query_first("$.foo")
# jsonb_path_query_first(json, '$.foo')

json_op.path_query_first("$.foo ? ($ > $x)", x: 2)
# jsonb_path_query_first(json, '$.foo ? ($ > $x)', '{"x":2}')

json_op.path_query_first("$.foo ? ($ > $x)", {x: 2}, true)
# jsonb_path_query_first(json, '$.foo ? ($ > $x)', '{"x":2}', true)

767
768
769
# File 'lib/sequel/extensions/pg_json_ops.rb', line 767

def path_query_first(path, vars=nil, silent=nil)
  JSONBOp.new(_path_function(:jsonb_path_query_first, path, vars, silent))
end