electric-sql / electric-sql/electric

Support mapping change stream to an Ecto.Schema embedded struct

Open
#2,530 0 comments 0 reactions 1 assignee Claimed by @magnetised View on GitHub
Dominant language
TypeScript
Stars
10.4k
Forks
375
Avg merge
3d 1h
Merged PRs (30d)
18

Description

Currently we only support db-backed ecto.schemas, but we can leverage the type casting powers of ecto by supporting embedded schemas and mapping any data to ecto schema structs

```elixir
defmodule MyModel do
use Ecto.Schema
embedded_schema do
field :name, :string
field :value, :integer
end
end

{:ok, client} = Electric.Client.new(base_url: "http://localhost:3000")
stream = Electric.Client.stream(client, "model", schema: MyModel)
```

This separates the pg table from the local data structures, which may not have a pg connection or any db-backed ecto schemas but allows for receiving nice %MyModel{} structs from the stream.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.