Ccxt.StructurePersistence (CCXT Elixir v0.1.0-binance-pro-preview)

Copy Markdown View Source

Database persistence plans for CCXT unified structures.

This module does not call a database and does not depend on Ecto. It turns the structure manifest into deterministic insert/upsert metadata that consuming applications can pass to their own Repo layer.

Summary

Types

operation()

@type operation() :: :insert | :upsert

plan()

@type plan() :: %{
  structure: String.t(),
  role: role(),
  table: String.t(),
  operation: operation(),
  conflict_target: [atom()],
  update_fields: [atom()],
  identity_fields: [atom()],
  fields: [atom()],
  source_methods: [String.t()]
}

role()

@type role() :: :canonical | :history

Functions

ecto_options(map)

@spec ecto_options(plan()) :: keyword()

normalize_and_plan(structure, value, opts \\ [])

@spec normalize_and_plan(
  Ccxt.StructureSchema.structure(),
  term(),
  Ccxt.StructureNormalizer.opts()
) ::
  {:ok, %{attrs: map() | [map()], plans: [plan()]}} | {:error, term()}

plan(structure, role \\ :canonical)

@spec plan(Ccxt.StructureSchema.structure(), role()) ::
  {:ok, plan()} | {:error, term()}

plans(structure)

@spec plans(Ccxt.StructureSchema.structure()) :: {:ok, [plan()]} | {:error, term()}

plans!(structure)

@spec plans!(Ccxt.StructureSchema.structure()) :: [plan()]

source_method_plans(method)

@spec source_method_plans(atom() | String.t()) :: {:ok, [plan()]} | {:error, term()}