Xitdb.Pull (xitdb v1.0.1)

Copy Markdown View Source

Compiles structured Elixir Pull patterns into canonical xitdb Pull syntax strings.

Examples

iex> Xitdb.Pull.compile!([:username, :age, todos: 0..2, profile: [:city]])
"{username, age, todos[0..2], profile{city}}"

iex> Xitdb.Pull.compile!([:*, friends: {0..5, [:username, profile: [:city]]}])
"{*, friends[0..5]{username, profile{city}}}"

Summary

Functions

Compiles a structural Pull pattern list or validates a Pull pattern binary.

Same as compile/1, but raises ArgumentError on invalid patterns.

Types

pattern()

@type pattern() :: String.t() | [pattern_entry()]

pattern_entry()

@type pattern_entry() ::
  atom()
  | String.t()
  | {atom() | String.t(), Range.t()}
  | {atom() | String.t(), {:slice, non_neg_integer(), non_neg_integer()}}
  | {atom() | String.t(), [pattern_entry()]}
  | {atom() | String.t(), {Range.t(), [pattern_entry()]}}
  | {atom() | String.t(),
     {{:slice, non_neg_integer(), non_neg_integer()}, [pattern_entry()]}}

Functions

compile(pattern)

@spec compile(pattern()) :: {:ok, String.t()} | {:error, Xitdb.Error.t()}

Compiles a structural Pull pattern list or validates a Pull pattern binary.

compile!(pattern)

@spec compile!(pattern()) :: String.t()

Same as compile/1, but raises ArgumentError on invalid patterns.