Appendix.Jsonb (appendix v0.0.5)

A module for building Ecto queries with JSONB columns.

This module provides a macro json_query/4 to generate dynamic where clauses for JSONB columns in an Ecto query.

Summary

Functions

Builds a dynamic where clause for JSONB columns in an Ecto query.

Functions

Link to this macro

json_query(qry, col, params, opts)

(macro)

Builds a dynamic where clause for JSONB columns in an Ecto query.

Parameters

  • qry: The initial query.
  • col: The JSONB column to query.
  • params: A keyword list of key-value pairs to match against the JSONB column.
  • opts: A keyword list of options. Supports :where_type, which can be :where or :or_where. Defaults to :where.

Examples

iex> import Ecto.Query
iex> query = from(p in Post)
iex> json_query(query, :metadata, [title: "Elixir", author: "José"], where_type: :where)
# Ecto query with JSONB where clauses