Milvex.Collection.Transformers.DefineStruct (milvex v0.10.2)

Copy Markdown

Transformer that generates a struct and @type t from the Collection DSL fields.

This makes Collection modules work like Ecto schemas - the field names from the DSL become struct fields with appropriate types.

Example

defmodule MyApp.Movies do
  use Milvex.Collection

  collection do
    name "movies"
    fields do
      primary_key :id, :int64
      varchar :title, 256
      vector :embedding, 128
    end
  end
end

# Generates:
# @type t :: %MyApp.Movies{id: integer(), title: String.t(), embedding: [float()]}
# defstruct [:id, :title, :embedding]

movie = %MyApp.Movies{id: 1, title: "Inception", embedding: [0.1, 0.2]}

Summary

Functions

after?(_)

Callback implementation for Spark.Dsl.Transformer.after?/1.

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.

before?(_)

Callback implementation for Spark.Dsl.Transformer.before?/1.