WalEx.TransactionFilter (WalEx v0.7.1) View Source
Link to this section Summary
Functions
Predicate to check if the filter matches the transaction.
Parse a string representing a relation filter to a Filter
struct.
Link to this section Functions
Predicate to check if the filter matches the transaction.
Examples
iex> txn = %Transaction{changes: [
...> %WalEx.Adapters.Changes.NewRecord{
...> columns: [
...> %WalEx.Adapters.Postgres.Decoder.Messages.Relation.Column{flags: [:key], name: "id", type: "int8", type_modifier: 4294967295},
...> %WalEx.Adapters.Postgres.Decoder.Messages.Relation.Column{flags: [], name: "details", type: "text", type_modifier: 4294967295},
...> %WalEx.Adapters.Postgres.Decoder.Messages.Relation.Column{flags: [], name: "user_id", type: "int8", type_modifier: 4294967295}
...> ],
...> commit_timestamp: nil,
...> record: %{"details" => "The SCSI system is down, program the haptic microchip so we can back up the SAS circuit!", "id" => "14", "user_id" => "1"},
...> schema: "public",
...> table: "todos",
...> type: "INSERT"
...> }
...> ]}
iex> matches?(%{event: "*", relation: "*"}, txn)
true
iex> matches?(%{event: "INSERT", relation: "*"}, txn)
true
iex> matches?(%{event: "UPDATE", relation: "*"}, txn)
false
iex> matches?(%{event: "INSERT", relation: "public"}, txn)
true
iex> matches?(%{event: "INSERT", relation: "myschema"}, txn)
false
iex> matches?(%{event: "INSERT", relation: "public:todos"}, txn)
true
iex> matches?(%{event: "INSERT", relation: "myschema:users"}, txn)
false
Parse a string representing a relation filter to a Filter
struct.
Examples
iex> parse_relation_filter("public:users")
{:ok, %Filter{schema: "public", table: "users", condition: nil}}
iex> parse_relation_filter("public")
{:ok, %Filter{schema: "public", table: nil, condition: nil}}
iex> parse_relation_filter("")
{:ok, %Filter{schema: nil, table: nil, condition: nil}}
iex> parse_relation_filter("public:users:bad")
{:error, "malformed relation filter"}