Skip to content

Setting values saved in database #14

Description

@jamilabreu

Hey @acalejos! 👋

Playing around with Flint, how would I control how an embedded_schema gets saved in the database? I have:

defmodule App.PersonData do
  use Flint.Schema, extensions: [Accessible, Embedded, JSON]

  embedded_schema do
    field :name, :string, omitempty: true
    field :slug, :string
  end
end
defmodule App.Person do
  use Flint.Schema

  schema "people" do
    embeds_one :data, App.PersonData
  end
end

When I Repo.insert! with the name field blank, the database still shows %{name: null}, but running Repo.insert! |> Jason.encode! returns the expected result

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions