Otzel.Ecto.Delta (otzel v0.5.1)

View Source

An Ecto type for storing Otzel deltas as JSON/JSONB.

This type allows you to store OT deltas directly in your database, automatically handling serialization to JSON for storage and deserialization back to Otzel operation structs on load.

Usage

defmodule MyApp.Document do
  use Ecto.Schema

  schema "documents" do
    field :content, Otzel.Ecto.Delta
    timestamps()
  end
end

Database Column

Use a :map type in your migration, which becomes jsonb in PostgreSQL:

create table(:documents) do
  add :content, :map
  timestamps()
end

Storage Format

Deltas are stored in the standard Quill Delta JSON format:

[
  {"insert": "Hello "},
  {"insert": "World", "attributes": {"bold": true}}
]

Summary

Functions

Callback implementation for Ecto.Type.embed_as/1.

Functions

embed_as(_)

Callback implementation for Ecto.Type.embed_as/1.