Class Sequel::Postgres::JSONBOp
In: lib/sequel/extensions/pg_json_ops.rb
Parent: JSONBaseOp

JSONBaseOp subclass for the jsonb type.

In the method documentation examples, assume that:

  jsonb_op = Sequel.pg_jsonb(:jsonb)

Methods

Constants

CONTAIN_ALL = ["(".freeze, " ?& ".freeze, ")".freeze].freeze
CONTAIN_ANY = ["(".freeze, " ?| ".freeze, ")".freeze].freeze
CONTAINS = ["(".freeze, " @> ".freeze, ")".freeze].freeze
CONTAINED_BY = ["(".freeze, " <@ ".freeze, ")".freeze].freeze
HAS_KEY = ["(".freeze, " ? ".freeze, ")".freeze].freeze

Public Instance methods

Check if the receiver contains all of the keys in the given array:

  jsonb_op.contain_all(:a) # (jsonb ?& a)

[Source]

     # File lib/sequel/extensions/pg_json_ops.rb, line 270
270:       def contain_all(other)
271:         bool_op(CONTAIN_ALL, wrap_input_array(other))
272:       end

Check if the receiver contains any of the keys in the given array:

  jsonb_op.contain_any(:a) # (jsonb ?| a)

[Source]

     # File lib/sequel/extensions/pg_json_ops.rb, line 277
277:       def contain_any(other)
278:         bool_op(CONTAIN_ANY, wrap_input_array(other))
279:       end

Check if the other jsonb contains all entries in the receiver:

  jsonb_op.contained_by(:h) # (jsonb <@ h)

[Source]

     # File lib/sequel/extensions/pg_json_ops.rb, line 291
291:       def contained_by(other)
292:         bool_op(CONTAINED_BY, wrap_input_jsonb(other))
293:       end

Check if the receiver contains all entries in the other jsonb:

  jsonb_op.contains(:h) # (jsonb @> h)

[Source]

     # File lib/sequel/extensions/pg_json_ops.rb, line 284
284:       def contains(other)
285:         bool_op(CONTAINS, wrap_input_jsonb(other))
286:       end

Check if the receiver contains the given key:

  jsonb_op.has_key?('a') # (jsonb ? 'a')

[Source]

     # File lib/sequel/extensions/pg_json_ops.rb, line 298
298:       def has_key?(key)
299:         bool_op(HAS_KEY, key)
300:       end
include?(key)

Alias for has_key?

Return the receiver, since it is already a JSONBOp.

[Source]

     # File lib/sequel/extensions/pg_json_ops.rb, line 304
304:       def pg_jsonb
305:         self
306:       end

[Validate]