Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9279d1a

Browse files
committed
Example about schema validation in readme.
1 parent6f99151 commit9279d1a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,25 @@ examples.
187187

188188
Same rules apply when you search inside objects and branchy structures.
189189

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+
CREATETABLEjs (
196+
idserial,
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+
190209
See our
191210
[pgconf.eu presentation](http://www.sai.msu.su/~megera/postgres/talks/pgconfeu-2014-jsquery.pdf)
192211
for more examples.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp