File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,25 @@ examples.
187
187
188
188
Same rules apply when you search inside objects and branchy structures.
189
189
190
+ Type checking operators and "every" placeholders are useful for document
191
+ schema validation. JsQuery matchig operator ` @@ ` is immutable and can be used
192
+ in CHECK constraint. See following example.
193
+
194
+ ``` sql
195
+ CREATE TABLE js (
196
+ id serial ,
197
+ data jsonb,
198
+ CHECK (data @@ '
199
+ name IS STRING AND
200
+ similar_ids.#: IS NUMERIC AND
201
+ points.#:(x IS NUMERIC AND y IS NUMERIC)' ::jsquery));
202
+ ```
203
+
204
+ In this example check constraint validates that in "data" jsonb column:
205
+ value of "name" key is string, value of "similar_ids" key is array of numerics,
206
+ value of "points" key is array of objects which contain numeric values in
207
+ "x" and "y" keys.
208
+
190
209
See our
191
210
[ pgconf.eu presentation] ( http://www.sai.msu.su/~megera/postgres/talks/pgconfeu-2014-jsquery.pdf )
192
211
for more examples.
You can’t perform that action at this time.
0 commit comments