Hoogle Search
Within LTS Haskell 24.32 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
(
#>. ) :: JSONBExpr a -> [Text] -> JSONBExpr besqueleto Database.Esqueleto.PostgreSQL.JSON Requires PostgreSQL version >= 9.3 This operator can be used to select a JSON value from deep inside another one. It only works on objects and arrays and will result in NULL (Nothing) when encountering any other JSON type. The Texts used in the right operand list will always select an object field, but can also select an index from a JSON array if that text is parsable as an integer. Consider the following:
x ^. TestBody #>. ["0","1"]
The following JSON values in the test table's body column will be affected:Values in column | Resulting value --------------------------------------+---------------------------- {"0":{"1":"Got it!"}} | "Got it!" {"0":[null,["Got it!","Even here!"]]} | ["Got it!", "Even here!"] [{"1":"Got it again!"}] | "Got it again!" [[null,{"Wow":"so deep!"}]] | {"Wow": "so deep!"} false | NULL "nope" | NULL 3.14 | NULLPostgreSQL Documentation
| Type | Description | Example | Example Result -----+--------+-----------------------------------+--------------------------------------------+---------------- #> | text[] | Get JSON object at specified path | '{"a": {"b":{"c": "foo"}}}'::json#>'{a,b}' | {"c": "foo"}(
#>>. ) :: JSONBExpr a -> [Text] -> SqlExpr (Value (Maybe Text))esqueleto Database.Esqueleto.PostgreSQL.JSON Requires PostgreSQL version >= 9.3 This function is to #>. as ->>. is to ->. CAUTION: if the "scalar" JSON value null is the result of this function, PostgreSQL will interpret it as a PostgreSQL NULL value, and will therefore be Nothing instead of (Just "null")
PostgreSQL Documentation
| Type | Description | Example | Example Result -----+--------+-------------------------------------------+---------------------------------------------+---------------- #>> | text[] | Get JSON object at specified path as text | '{"a":[1,2,3],"b":[4,5,6]}'::json#>>'{a,2}' | 3(
--. ) :: JSONBExpr a -> [Text] -> JSONBExpr besqueleto Database.Esqueleto.PostgreSQL.JSON Requires PostgreSQL version >= 10 Removes a set of keys from an object, or string elements from an array. This is the same operator internally as -., but the option to use a text array, instead of text or integer was only added in version 10. That's why this function is seperate from -. NOTE: The following is equivalent:
{some JSON expression} -. "a" -. "b"is equivalent to{some JSON expression} --. ["a","b"]PostgreSQL Documentation
| Type | Description | Example ---+---------+------------------------------------------------------------------------+------------------------------------------------- - | text[] | Delete multiple key/value pairs or string elements from left operand. | '{"a": "b", "c": "d"}'::jsonb - '{a,c}'::text[] | | Key/value pairs are matched based on their key value. |(
-. ) :: JSONBExpr a -> JSONAccessor -> JSONBExpr besqueleto Database.Esqueleto.PostgreSQL.JSON Requires PostgreSQL version >= 9.5 This operator can remove a key from an object or a string element from an array when using text, and remove certain elements by index from an array when using integers. Negative integers delete counting from the end of the array. (e.g. -1 being the last element, -2 being the second to last, etc.) CAUTION: THIS FUNCTION THROWS AN EXCEPTION WHEN USED ON ANYTHING OTHER THAN OBJECTS OR ARRAYS WHEN USING TEXT, AND ANYTHING OTHER THAN ARRAYS WHEN USING INTEGERS!
Objects and arrays
{"a": 3.14} - "a" == {} {"a": "b"} - "b" == {"a": "b"} {"a": 3.14} - "a" == {} {"a": 3.14, "c": true} - "a" == {"c": true} ["a", 2, "c"] - "a" == [2, "c"] -- can remove strings from arrays [true, "b", 5] - 0 == ["b", 5] [true, "b", 5] - 3 == [true, "b", 5] [true, "b", 5] - -1 == [true, "b"] [true, "b", 5] - -4 == [true, "b", 5] [] - 1 == [] {"1": true} - 1 == ERROR: cannot delete from object using integer index 1 - <anything> == ERROR: cannot delete from scalar "a" - <anything> == ERROR: cannot delete from scalar true - <anything> == ERROR: cannot delete from scalar null - <anything> == ERROR: cannot delete from scalarPostgreSQL Documentation
| Type | Description | Example ---+---------+------------------------------------------------------------------------+------------------------------------------------- - | text | Delete key/value pair or string element from left operand. | '{"a": "b"}'::jsonb - a | | Key/value pairs are matched based on their key value. | - | integer | Delete the array element with specified index (Negative integers count | '["a", "b"]'::jsonb - 1 | | from the end). Throws an error if top level container is not an array. |(
->. ) :: JSONBExpr a -> JSONAccessor -> JSONBExpr besqueleto Database.Esqueleto.PostgreSQL.JSON Requires PostgreSQL version >= 9.3 This function extracts the jsonb value from a JSON array or object, depending on whether you use an int or a text. (cf. JSONAccessor) As long as the left operand is jsonb, this function will not throw an exception, but will return NULL when an int is used on anything other than a JSON array, or a text is used on anything other than a JSON object.
PostgreSQL Documentation
| Type | Description | Example | Example Result ----+------+--------------------------------------------+--------------------------------------------------+---------------- -> | int | Get JSON array element (indexed from zero) | '[{"a":"foo"},{"b":"bar"},{"c":"baz"}]'::json->2 | {"c":"baz"} -> | text | Get JSON object field by key | '{"a": {"b":"foo"}}'::json->a | {"b":"foo"}(
->>. ) :: JSONBExpr a -> JSONAccessor -> SqlExpr (Value (Maybe Text))esqueleto Database.Esqueleto.PostgreSQL.JSON Requires PostgreSQL version >= 9.3 Identical to ->., but the resulting DB type is a text, so it could be chained with anything that uses text. CAUTION: if the "scalar" JSON value null is the result of this function, PostgreSQL will interpret it as a PostgreSQL NULL value, and will therefore be Nothing instead of (Just "null")
PostgreSQL Documentation
| Type | Description | Example | Example Result -----+------+--------------------------------+-----------------------------+---------------- ->> | int | Get JSON array element as text | '[1,2,3]'::json->>2 | 3 ->> | text | Get JSON object field as text | '{"a":1,"b":2}'::json->>b | 2(
<@. ) :: JSONBExpr a -> JSONBExpr b -> SqlExpr (Value Bool)esqueleto Database.Esqueleto.PostgreSQL.JSON Requires PostgreSQL version >= 9.4 This operator works the same as @>., just with the arguments flipped. So it checks for the JSON value on the left to be a subset of JSON value on the right. Examples of the usage of this operator can be found in the Database.Persist.Postgresql.JSON module. (here: https://hackage.haskell.org/package/persistent-postgresql-2.10.0/docs/Database-Persist-Postgresql-JSON.html)
PostgreSQL Documentation
| Type | Description | Example ----+-------+----------------------------------------------------------+--------------------------------------------- <@ | jsonb | Is the left JSON value contained within the right value? | '{"b":2}'::jsonb <@ '{"a":1, "b":2}'::jsonb(
?&. ) :: JSONBExpr a -> [Text] -> SqlExpr (Value Bool)esqueleto Database.Esqueleto.PostgreSQL.JSON Requires PostgreSQL version >= 9.4 This operator checks if ALL of the given texts are top-level members of the JSON value on the left. This means a top-level field in an object, a top-level string in an array or just a string value. Examples of the usage of this operator can be found in the Database.Persist.Postgresql.JSON module. (here: https://hackage.haskell.org/package/persistent-postgresql-2.10.0/docs/Database-Persist-Postgresql-JSON.html)
PostgreSQL Documentation
| Type | Description | Example ----+--------+--------------------------------------------------------+---------------------------------------- ?& | text[] | Do all of these array strings exist as top-level keys? | '["a", "b"]'::jsonb ?& array[a, b]
(
?. ) :: JSONBExpr a -> Text -> SqlExpr (Value Bool)esqueleto Database.Esqueleto.PostgreSQL.JSON Requires PostgreSQL version >= 9.4 This operator checks if the given text is a top-level member of the JSON value on the left. This means a top-level field in an object, a top-level string in an array or just a string value. Examples of the usage of this operator can be found in the Database.Persist.Postgresql.JSON module. (here: https://hackage.haskell.org/package/persistent-postgresql-2.10.0/docs/Database-Persist-Postgresql-JSON.html)
PostgreSQL Documentation
| Type | Description | Example ---+------+-----------------------------------------------------------------+------------------------------- ? | text | Does the string exist as a top-level key within the JSON value? | '{"a":1, "b":2}'::jsonb ? b(
?|. ) :: JSONBExpr a -> [Text] -> SqlExpr (Value Bool)esqueleto Database.Esqueleto.PostgreSQL.JSON Requires PostgreSQL version >= 9.4 This operator checks if ANY of the given texts is a top-level member of the JSON value on the left. This means any top-level field in an object, any top-level string in an array or just a string value. Examples of the usage of this operator can be found in the Database.Persist.Postgresql.JSON module. (here: https://hackage.haskell.org/package/persistent-postgresql-2.10.0/docs/Database-Persist-Postgresql-JSON.html)
PostgreSQL Documentation
| Type | Description | Example ----+--------+--------------------------------------------------------+--------------------------------------------------- ?| | text[] | Do any of these array strings exist as top-level keys? | '{"a":1, "b":2, "c":3}'::jsonb ?| array[b, c]