com presentations: Added missing content: slides/mongodb/scalar-query-postgresql-jsonb.xml
[email protected] (Derick Rethans) Wed, 20 Feb 2019 12:19:16 +0000
| Newsgroups | php.pres |
|---|---|
| Message-ID | <[email protected]> |
Commit: b7ef2c4796c6dd76ee94592c96d1d64ca1ee892e Author: Derick Rethans <[email protected]> Wed, 20 Feb 2019 12:19:16 +0000 Parents: fe6d479b9ae23e45fc8073b87a11a20f18533be8 Branches: master Link: http://git.php.net/?p=presentations.git;a=commitdiff;h=b7ef2c4796c6dd76ee94592c96d1d64ca1ee892e Log: Added missing content Changed paths: M slides/mongodb/scalar-query-postgresql-jsonb.xml Diff: diff --git a/slides/mongodb/scalar-query-postgresql-jsonb.xml b/slides/mongodb/scalar-query-postgresql-jsonb.xml index 007bc65..2343b39 100644 --- a/slides/mongodb/scalar-query-postgresql-jsonb.xml +++ b/slides/mongodb/scalar-query-postgresql-jsonb.xml @@ -1,4 +1,33 @@ <slide> <title>PostgreSQL: Query JSONB</title> +<example inline="2"> +INSERT INTO users VALUES('{ + "_id" : "derick@localhost", + "email" : "derick@localhost", + "words" : [ "derick", "rethans", "london", "uk" ] +}'); +</example> + +You might add a B-tree index on hdoc->>'email'; + +<blurb>Find %_id% for %email% address (B-tree-index):</blurb> +<example inline="2"> +SELECT hdoc->>'_id' FROM users WHERE *hdoc->>'email'* = 'derick@localhost'; +</example> + +<blurb>Find %users% without a %country% value set:</blurb> +<example inline="2"> +SELECT hdoc->>'_id' FROM users WHERE hdoc->>'country' IS NOT NULL; +</example> + +<blurb>Find users where %words% includes %london% (GIN index):</blurb> +<example inline="2"> +SELECT \* FROM users WHERE *hdoc* @> '{"words": ["london"]}'; +</example> + +<blurb>Update or add field:</blurb> +<example inline="2"> +UPDATE users SET hdoc = hdoc || '{"country": "Europe"}'; +</example> </slide>