]> git.8kb.co.uk Git - postgresql/pg_jsonb_opx/blobdiff - README.md
Had a play at making the following changes today, some will be a bit ugly as just...
[postgresql/pg_jsonb_opx] / README.md
index 7933507de7c41d40450f403f6a8087ed5b7b8621..b1406e3fe0a03b2b9e172f3946c9da130e090940 100755 (executable)
--- a/README.md
+++ b/README.md
 jsonb_opx
 =========
 
-Missing operators for jsonb in PostgreSQL 9.4, this may contain some errors and bad form so please test that it suits your requirements before using in any production scenario.
+Missing operators for jsonb in PostgreSQL 9.4, this may contain some errors and bad form as it's primarily just experimentation (i'm not a frequent C programmer; but everyone has to start somewhere right?).  Please test that it suits your requirements before using in any production scenario.
 
 Provides
 --------
 
+The following behave like hstore 1.x operators, i.e. without nested jsonb traversal
+
 * deletion using **-** operator
   * jsonb_delete(jsonb, text)
   * jsonb_delete(jsonb, text[])
   * jsonb_delete(jsonb, jsonb)
 * concatenation using **||** operator
   * jsonb_concat(jsonb, jsonb)
+* replacement using **=#** operator
+  * jsonb_replace(jsonb, jsonb)
 
-More detail
------------
-* delete operator **"-"** provided by functions *jsonb_delete(jsonb, text) jsonb_delete(jsonb, text[]) and jsonb_delete(jsonb, jsonb)*
-    Provides:
-        jsonb - text
-        jsonb - text[]
-        jsonb - jsonb
-
-    Note: When using text type operators on jsonb arrays only elements of type text will be deleted. E.g.
-
-```sql
-TEST=# SELECT '[1, "1", "2", 2]'::jsonb - '2'::text;
-  ?column?   
--------------
- [1, "1", 2]
-(1 row)
-
-TEST=# SELECT '[1, "1", "2", 2]'::jsonb - '"2"'::text;
-     ?column?     
-------------------
- [1, "1", "2", 2]
-(1 row)
-
-TEST=# SELECT '[1, "1", "2", 2]'::jsonb - array['2']::text[];
-  ?column?   
--------------
- [1, "1", 2]
-(1 row)
-
-TEST=# SELECT '[1, "1", "2", 2]'::jsonb - array['"2"']::text[];
-     ?column?     
-------------------
- [1, "1", "2", 2]
-(1 row)
-
-```
-
-    More. E.g.
-```sql
-TEST=# SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb - 'b'::text;
-     ?column?     
-------------------
- {"a": 1, "c": 3}
-(1 row)
-
-TEST=# SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb - ARRAY['a','b'];
- ?column? 
-----------
- {"c": 3}
-(1 row)
-
-TEST=# SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb - '{"a": 4, "b": 2}'::jsonb;
-     ?column?     
-------------------
- {"a": 1, "c": 3}
-(1 row)
-
-TEST=# SELECT '{"a": 1, "b": 2, "c": 3, "d": {"a": 4}}'::jsonb - '{"d": {"a": 4}, "b": 2}'::jsonb;
-     ?column?     
-------------------
- {"a": 1, "c": 3}
-(1 row)
-
-TEST=# SELECT '{"a": 4, "b": 2, "c": 3, "d": {"a": 4}}'::jsonb - '{"a": 4, "b": 2}'::jsonb;
-        ?column?         
--------------------------
- {"c": 3, "d": {"a": 4}}
-(1 row)
-```
-    
-* concatenation operator  **"||"** provided by function *jsonb_concat(jsonb, jsonb)*
-    Provides:
-         jsonb || jsonb
-
-    E.g.
-
-```sql
-TEST=#  SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb || '{"a": 4, "b": 2, "d": 4}'::jsonb;
-             ?column?             
-----------------------------------
- {"a": 4, "b": 2, "c": 3, "d": 4}
-(1 row)
-
-TEST=#  SELECT '["a", "b"]'::jsonb || '["c"]'::jsonb;
-    ?column?     
------------------
- ["a", "b", "c"]
-(1 row)
-
-TEST=#  SELECT '[1,2,3]'::jsonb || '[3,4,5]'::jsonb;
-      ?column?      
---------------------
- [1, 2, 3, 3, 4, 5]
-(1 row)
-
-TEST=#  SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb || '[1,2,3]'::jsonb;
-              ?column?               
--------------------------------------
- [{"a": 1, "b": 2, "c": 3}, 1, 2, 3]
-(1 row)
+The following are intended to eventually function like hstor 2.0 operators
 
-TEST=#  SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb || '[1,2,3]'::jsonb || '"a"'::jsonb;
-                 ?column?                 
-------------------------------------------
- [{"a": 1, "b": 2, "c": 3}, 1, 2, 3, "a"]
-(1 row)
-```
+* deletion at chained path using **#-** operator
+    jsonb_delete_path(jsonb, text[])
+* replacement at chained path using function
+    jsonb_replace_path(jsonb, text[], jsonb)