Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View josephwecker's full-sized avatar

Joseph Wecker josephwecker

View GitHub Profile
@josephwecker
josephwecker / pgstore.rb
Created March 28, 2018 23:24 — forked from noteflakes/pgstore.rb
A lightweight PostgreSQL ORM using JSONB. Provides an API for retreiving documents by arbitrary key, and performing queries on arbitrary keys and sub-keys.
require 'pg'
PGDB = PG.connect(host: '/tmp', dbname: 'mydb')
PGDB.type_map_for_results = PG::BasicTypeMapForResults.new(PGDB)
class Hash
def symbolize_keys
inject({}) { |m, kv| v = kv[1];
m[kv[0].to_sym] = v.is_a?(Hash) ? v.symbolize_keys : v; m }
end
end