PhoenixLiveCalendar.Store.EventStore behaviour
(PhoenixLiveCalendar v0.1.0)
Copy Markdown
View Source
Behaviour defining the data access interface for calendar events.
Implement this behaviour to provide custom persistence.
A default Ecto implementation is provided in PhoenixLiveCalendar.Store.Ecto.EventStoreEcto.
Example custom implementation
defmodule MyApp.InMemoryEventStore do
@behaviour PhoenixLiveCalendar.Store.EventStore
@impl true
def list_events(opts) do
# Your custom implementation
end
@impl true
def get_event(id, _opts) do
# Your custom implementation
end
# ... etc
endConfigure your store:
config :phoenix_live_calendar, event_store: MyApp.InMemoryEventStore
Summary
Callbacks
Creates a new event. Returns {:ok, event} or {:error, changeset}.
Deletes an event by ID.
Fetches a single event by ID.
Lists events within a date range.
Updates an existing event.
Types
Callbacks
@callback create_event(map(), opts()) :: {:ok, PhoenixLiveCalendar.Event.t()} | {:error, term()}
Creates a new event. Returns {:ok, event} or {:error, changeset}.
Deletes an event by ID.
@callback get_event(event_id(), opts()) :: PhoenixLiveCalendar.Event.t() | nil
Fetches a single event by ID.
@callback list_events(opts()) :: [PhoenixLiveCalendar.Event.t()]
Lists events within a date range.
Options
:start— Range start (Date or DateTime):end— Range end (Date or DateTime, exclusive):resource_id— Filter by resource:calendar_id— Filter by calendar:limit— Maximum events to return
@callback update_event(event_id(), map(), opts()) :: {:ok, PhoenixLiveCalendar.Event.t()} | {:error, term()}
Updates an existing event.