Lethe.Query (Lethe v0.3.0) View Source
A Lethe query. Queries are what Lethe transforms into Mnesia-compatible
matchspecs for processing. A query is constructed from nothing but a table
name, provided to Lethe.new/1
. Queries have sane defaults:
- Return all fields
- Read lock
- Return all matches
Queries can be updated with several functions:
Lethe.where/2
: Add a constraint to the query, like aWHERE
clause in SQL.Lethe.limit/2
: Limit the number of results returned by the query.Lethe.select/2
: Choose the specific fields returned by the query.Lethe.select_all/1
: Choose to return all fields.
When you're finished creating a query, you must then compile it with
Lethe.compile/1
, which converts the query into a form that can be passed
to Mnesia. Copmiled queries can be executed with Lethe.run/1
; while it is
possible to take the output from Lethe.compile/1
and run it manually,
doing so is not advised.
Link to this section Summary
Link to this section Types
Specs
t() :: %Lethe.Query{ fields: %{required(Lethe.field()) => non_neg_integer()} | nil, limit: Lethe.limit() | nil, lock: Lethe.lock() | nil, ops: [Lethe.matchspec_condition()] | nil, select: [Lethe.field()] | nil, table: Lethe.table() | nil }