class Perpetuity::Postgres::QueryAttribute

Attributes

name[R]

Public Class Methods

new(name) click to toggle source
# File lib/perpetuity/postgres/query_attribute.rb, line 9
def initialize name
  @name = name
end

Public Instance Methods

any?() click to toggle source
# File lib/perpetuity/postgres/query_attribute.rb, line 33
def any?
  QueryExpression.new count, :>, 0
end
count() click to toggle source
# File lib/perpetuity/postgres/query_attribute.rb, line 29
def count
  SQLFunction.new('json_array_length', self)
end
id() click to toggle source
# File lib/perpetuity/postgres/query_attribute.rb, line 41
def id
  QueryAttribute.new "#{name}->'__metadata__'->>'id'"
end
in(collection) click to toggle source
# File lib/perpetuity/postgres/query_attribute.rb, line 21
def in collection
  QueryExpression.new self, :in, collection
end
nil?() click to toggle source
# File lib/perpetuity/postgres/query_attribute.rb, line 25
def nil?
  QueryExpression.new self, :==, nil
end
none?() click to toggle source
# File lib/perpetuity/postgres/query_attribute.rb, line 37
def none?
  QueryExpression.new count, :==, 0
end
to_db() click to toggle source
# File lib/perpetuity/postgres/query_attribute.rb, line 49
def to_db
  (self != nil).to_db
end
to_s() click to toggle source
# File lib/perpetuity/postgres/query_attribute.rb, line 45
def to_s
  name.to_s
end