Copyright © 2018-2020 Klarna Bank AB (publ)
This module inserts a batch of Erlang maps as rows in a Postgres table.
[ #{field1 => val1, field2 => val2}
, #{field1 => val3, field2 => val4}
]
Input message is returned as is.
Configuration is a term of config/0 type. It's a map with
the following mandatory fields:
database PostgreSQL connection options, see
https://github.com/epgsql/epgsql/blob/devel/src/epgsql.erl#L49table is name of Postgres table used for storing
datafields is a list of map keys that should be inserted to the
table. By default, table column with the name matching will be
usedThe following options are optional:
field_mappings allows to specify column names used for
the keys. This value should be a map #{Key => ColumnName}keys parameter allows to specify which columens are primary
keys in the table. kflow_postgres will overwrite row with
colliding keys via upsert. {map, kflow_postgres, #{ database => #{ host => "localhost"
, user => "kflow"
, password => "123"
, database => "postgres"
, port => 5432
}
, table => "foo_table"
, fields => [foo, bar, baz]
, keys => [foo]
}}
config() = #{database := epgsql:connect_opts(), init_count => non_neg_integer(), fields := [field()], keys => [field()], table := list() | binary(), field_mappings => field_mappings()}
field() = atom() | list() | binary()
field_mappings() = #{field() => field()}
Generated by EDoc