View Source Watching without a schema
Since ecto supports working with tables withoun needed a schema, you may also want to create EctoWatch watchers without needing to create a schema like so:
# setup
{EctoWatch,
repo: MyApp.Repo,
pub_sub: MyApp.PubSub,
watchers: [
{
%{
table_name: "comments",
primary_key: :ID,
column_map: %{body: :bodyContent},
columns: [:title, :body, :author_id, :post_id],
association_columns: [:author_id, :post_id]
}, :updated, extra_columns: [:post_id]
}
]}Everything works the same as with a schema, though make sure to specify your association columns if you want to subscribe to an association column.
Supported keys for configuring a table without a schema:
schema_prefix(optional, defaults topublic)table_name(required)primary_key(optional, defaults toid)column_map(optional, defaults to%{})columns(optional, defaults to[])association_columns(optional, defaults to[])