xerions/ecto_subscribe

Name: ecto_subscribe

Owner: xerions

Description: Ecto plugin for possibility to have generic subscription on data

Created: 2015-03-13 11:50:26.0

Updated: 2018-02-21 08:05:26.0

Pushed: 2015-04-17 11:10:37.0

Homepage: null

Size: 178

Language: Elixir

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

EctoSubscribe

ecto_subscribe allows to subscribe on change a model.

Usage

You can define your ecto model and use subscribe macro:

rt Ecto.Subscribe.Api

odule MyModel do
e Ecto.Model

bscribe(repo: MyRepo)
hema "user" do
field :name,    :string
field :old, :integer
d

After this tell to the ecto_subscribe about your repo and subcribe on event with:

.Subscribe.init(MyRepo)
.Subscribe.Api.subscribe(MyRepo, MyModel, "old > 20", [adapter: Ecto.Subscribe.Adapter.Log actions: [:create]])

When any event will occur, ecto_subscribe will write to log this.

ecto_subcribe supports following adapters:

ecto_subscribe supports following actions:

If actions option not given, subscription will be created for all three events.

Testing

For running unut tests execute:

ENV=pg mix test

or

ENV=mysql mix test

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.