What are different way to define Schema in elixir

I am going through some code base(big project) and and i saw the code to create schema in schema directory

  def register_fcm_schema() do
    %{
      type: "object",
      schema: %{
        user_id: %{
          type: "int_or_string",
          required: true
        },
        device_id: %{
          type: "string",
          required: true
        },
        fcm_token: %{
          type: "string",
          required: true
        }
      }
    }
  end

and in ecto module i saw different definition

defmodule Friends.Person do
  use Ecto.Schema

  schema "people" do
    field :name, :string
    field :age, :integer, default: 0
  end
end

help me out to understand what is the meaning of first code -->( def register_fcm_schema() )??
what exectly it trying to define?? and how many way we can create schema??

In the first snippet Ecto is not used at all, as FCM means Firebase Cloud Messaging, and it has a different API which doesn’t match Ecto.

1 Like