LemonCrud.QueryBuilder (lemon_crud v0.1.0)

Builds queries based on conditions defined as keyword lists.

Example

query = LemonCrud.QueryBuilder.build_query(MyApp.Inventory.Item, [
  part_number: "1234567890",
  category: "electronics",
  manufacturer: [name: "Acme"]
])

# This will generate the following query:
#
# from i in MyApp.Inventory.Item,
#   join: m in assoc(i, :manufacturer),
#   where: i.category == "electronics" and m.name == "Acme" and i.part_number == "1234567890"

Summary

Functions

Builds a query based on the given schema and conditions.

Functions

build_query(schema, conditions, opts \\ [])

Builds a query based on the given schema and conditions.

Automatically joins associations based on the conditions.

Example

query = LemonCrud.QueryBuilder.build_query(MyApp.Inventory.Item, [
  part_number: "1234567890",
  category: "electronics",
  manufacturer: [name: "Acme"]
])

# This will generate the following query:
#
# from i in MyApp.Inventory.Item,
#   join: m in assoc(i, :manufacturer),
#   where: i.category == "electronics" and m.name == "Acme" and i.part_number == "1234567890"