Selecto.Advanced.JsonOperations
(Selecto v0.4.5)
Copy Markdown
JSON operations support for PostgreSQL JSON and JSONB functionality.
Provides comprehensive support for JSON path queries, aggregation, manipulation, and testing functions. Works with both JSON and JSONB column types with automatic type detection and optimization.
Examples
# JSON path extraction
selecto
|> Selecto.select([
{:json_extract, "metadata", "$.category", as: "category"},
{:json_extract, "metadata", "$.specs.weight", as: "weight"}
])
# JSON aggregation
selecto
|> Selecto.select([
{:json_agg, "product_name", as: "products"},
{:json_object_agg, "product_id", "price", as: "price_map"}
])
|> Selecto.group_by(["category"])
# JSON filtering
selecto
|> Selecto.filter([
{:json_contains, "metadata", %{"category" => "electronics"}},
{:json_path_exists, "metadata", "$.specs.warranty"}
])
Summary
Functions
Create a JSON extraction operation specification.
Determine if an operation is suitable for WHERE clauses.
Determine if an operation is suitable for SELECT clauses.
Validate a JSON operation specification.
Functions
Create a JSON extraction operation specification.
Determine if an operation is suitable for WHERE clauses.
Determine if an operation is suitable for SELECT clauses.
Validate a JSON operation specification.