JSON Fields¶
PGSync supports Postgres JSON and JSONB operators. This allows you to extract data within JSON fields.
These operators are defined here
For example, given a Postgres JSON field called doc
To extract the fourth element of the {a, b, c} path, define this schema
[
{
"database": "book",
"index": "book",
"nodes": {
"table": "book",
"schema": "my_book_library",
"columns": [
"doc#>{a,b,c}->4"
]
}
}
]
We can define this JSON schema, to get the first array element of field x.
[
{
"database": "book",
"index": "book",
"nodes": {
"table": "book",
"schema": "my_book_library",
"columns": [
"doc->x->0"
]
}
}
]
Info
doc is the field name in the database