groundhog-postgresql-0.12: PostgreSQL backend for the groundhog library.
Safe HaskellNone
LanguageHaskell2010

Database.Groundhog.Postgresql.HStore

Description

See detailed documentation for PostgreSQL HStore at http://www.postgresql.org/docs/9.3/static/hstore.html

Synopsis

HStore manipulation

(->.) :: (db ~ Postgresql, ExpressionOf db r hstore HStore, ExpressionOf db r key key', IsString key') => hstore -> key -> Expr db r (Maybe Text) Source #

Get value for key (NULL if not present)

'a=>x, b=>y'::hstore -> a == x

lookupArr :: (db ~ Postgresql, ExpressionOf db r hstore HStore, ExpressionOf db r keys (Array Text)) => hstore -> keys -> Expr db r (Array Text) Source #

Get values for keys array (NULL if not present)

'a=>x, b=>y, c=>z'::hstore == ARRAY[c,a]  {"z","x"}

hstoreConcat :: (db ~ Postgresql, ExpressionOf db r hstore1 HStore, ExpressionOf db r hstore2 HStore) => hstore1 -> hstore2 -> Expr db r HStore Source #

Concatenate hstores

'a=>b, c=>d'::hstore || 'c=>x, d=>q'::hstore == "a"=>"b", "c"=>"x", "d"=>"q"

deleteKey :: (db ~ Postgresql, ExpressionOf db r hstore HStore, ExpressionOf db r key key', IsString key') => hstore -> key -> Expr db r HStore Source #

Delete key from left operand

'a=>1, b=>2, c=>3'::hstore - b::text == "a"=>"1", "c"=>"3"

deleteKeys :: (db ~ Postgresql, ExpressionOf db r hstore HStore, ExpressionOf db r keys (Array Text)) => hstore -> keys -> Expr db r HStore Source #

Delete keys from left operand

'a=>1, b=>2, c=>3'::hstore - ARRAY[a,b] == "c"=>"3"

difference :: (db ~ Postgresql, ExpressionOf db r hstore1 HStore, ExpressionOf db r hstore2 HStore) => hstore1 -> hstore2 -> Expr db r HStore Source #

Delete matching pairs from left operand

'a=>1, b=>2, c=>3'::hstore - 'a=>4, b=>2'::hstore == "a"=>"1", "c"=>"3"

hstore_to_array :: (db ~ Postgresql, ExpressionOf db r hstore HStore) => hstore -> Expr db r (Array Text) Source #

Convert hstore to array of alternating keys and values. Same as prefix operator %%.

hstore_to_array('a=>1,b=>2') == {a,1,b,2}

hstore_to_matrix :: (db ~ Postgresql, ExpressionOf db r hstore HStore) => hstore -> Expr db r (Array (Array Text)) Source #

Convert hstore to two-dimensional key/value array. Same as prefix operator %#.

hstore_to_matrix('a=>1,b=>2') == {{a,1},{b,2}}

akeys :: (db ~ Postgresql, ExpressionOf db r hstore HStore) => hstore -> Expr db r (Array Text) Source #

Get hstore's keys as an array

akeys('a=>1,b=>2') == {a,b}

avals :: (db ~ Postgresql, ExpressionOf db r hstore HStore) => hstore -> Expr db r (Array Text) Source #

Get hstore's values as an array

avals('a=>1,b=>2') == {1,2}

slice :: (db ~ Postgresql, ExpressionOf db r hstore HStore, ExpressionOf db r keys (Array Text)) => hstore -> keys -> Expr db r HStore Source #

Extract a subset of an hstore

slice('a=>1,b=>2,c=>3'::hstore, ARRAY[b,c,x]) =="b"=>"2", "c"=>"3"

hstore_to_json :: (db ~ Postgresql, ExpressionOf db r hstore HStore) => hstore -> Expr db r Value Source #

Get hstore as a json value

hstore_to_json('"a key"=>1, b=>t, c=>null, d=>12345, e=>012345, f=>1.234, g=>2.345e+4')
 == {"a key": "1", "b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4"}

hstore_to_json_loose :: (db ~ Postgresql, ExpressionOf db r hstore HStore) => hstore -> Expr db r Value Source #

Get hstore as a json value, but attempting to distinguish numerical and Boolean values so they are unquoted in the JSON

hstore_to_json_loose('"a key"=>1, b=>t, c=>null, d=>12345, e=>012345, f=>1.234, g=>2.345e+4')
 == {"a key": 1, "b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4}

HStore conditions

exist :: (db ~ Postgresql, ExpressionOf db r hstore HStore, ExpressionOf db r key key', IsString key') => hstore -> key -> Cond db r Source #

Does hstore contain key? Same as postgresql operator ?.

'a=>1'::hstore ? a == True

defined :: (db ~ Postgresql, ExpressionOf db r hstore HStore, ExpressionOf db r key key', IsString key') => hstore -> key -> Cond db r Source #

Does hstore contain non-NULL value for key?

defined('a=>NULL',a) == f

(?&) :: (db ~ Postgresql, ExpressionOf db r hstore HStore, ExpressionOf db r keys (Array Text)) => hstore -> keys -> Cond db r Source #

Does hstore contain all specified keys?

'a=>1,b=>2'::hstore ?& ARRAY[a,b] == True

(?|) :: (db ~ Postgresql, ExpressionOf db r hstore HStore, ExpressionOf db r keys (Array Text)) => hstore -> keys -> Cond db r Source #

Does hstore contain any of the specified keys?

'a=>1,b=>2'::hstore ?| ARRAY[b,c] == True

(@>) :: (db ~ Postgresql, ExpressionOf db r hstore1 HStore, ExpressionOf db r hstore2 HStore) => hstore1 -> hstore2 -> Cond db r Source #

Does left operand contain right?

'a=>b, b=>1, c=>NULL'::hstore > 'b=>1' == True@

(<@) :: (db ~ Postgresql, ExpressionOf db r hstore1 HStore, ExpressionOf db r hstore2 HStore) => hstore1 -> hstore2 -> Cond db r Source #

Is left operand contained in right?

'a=>c'::hstore < 'a=>b, b=>1, c=>NULL' == False@