WalEx.TransactionFilter (WalEx v0.7.1) View Source

Link to this section Summary

Link to this section Functions

Link to this function

changes(old_record, record)

View Source
Link to this function

delete_event?(relation, txn)

View Source
Link to this function

has_table?(change, table_name)

View Source
Link to this function

has_tables?(tables, txn)

View Source
Link to this function

insert_event?(relation, txn)

View Source

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
Link to this function

parse_relation_filter(relation)

View Source

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"}
Link to this function

update_event?(relation, txn)

View Source