class Actn::DB::Set
Attributes
schema[RW]
table[RW]
Public Class Methods
[](table)
click to toggle source
# File lib/actn/db/set.rb, line 13 def self.[]table self.tables[table] ||= new(table) end
new(schema = :public, table)
click to toggle source
# File lib/actn/db/set.rb, line 19 def initialize schema = :public, table self.table = table self.schema = schema end
tables()
click to toggle source
# File lib/actn/db/set.rb, line 9 def self.tables @@tables ||= {} end
Public Instance Methods
all()
click to toggle source
# File lib/actn/db/set.rb, line 44 def all where({}) end
count(conds = {})
click to toggle source
# File lib/actn/db/set.rb, line 39 def count conds = {} exec_func :query, schema, table, {select: 'COUNT(id)'}.merge(conds).to_json end
delete_all()
click to toggle source
# File lib/actn/db/set.rb, line 60 def delete_all delete({}) end
find(uuid)
click to toggle source
# File lib/actn/db/set.rb, line 56 def find uuid find_by(uuid: uuid) end
find_by(cond)
click to toggle source
# File lib/actn/db/set.rb, line 52 def find_by cond query({where: cond,limit: 1})[1..-2] end
validate_and_upsert(data)
click to toggle source
# File lib/actn/db/set.rb, line 33 def validate_and_upsert data sql = "SELECT __upsert($1,$2,__validate($3,$4))" exec_prepared sql.parameterize.underscore, sql, [schema, table, table.classify, data.to_json] end
where(cond)
click to toggle source
# File lib/actn/db/set.rb, line 48 def where cond query({where: cond}) end