init: inital commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
defmodule Localiser.Domain.Schema.SensorCalibration do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Localiser.Domain.Schema.Sensor
|
||||
|
||||
@timestamps_opts [inserted_at: :inserted_at, updated_at: false, type: :utc_datetime]
|
||||
|
||||
schema "sensor_calibrations" do
|
||||
field :rssi_ref, :integer
|
||||
field :path_loss_exp, :float
|
||||
field :calibrated_at, :utc_datetime
|
||||
|
||||
belongs_to :sensor, Sensor
|
||||
|
||||
timestamps(@timestamps_opts)
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(calibration, attrs) do
|
||||
calibration
|
||||
|> cast(attrs, [:sensor_id, :rssi_ref, :path_loss_exp, :calibrated_at])
|
||||
|> validate_required([:sensor_id, :rssi_ref, :path_loss_exp, :calibrated_at])
|
||||
|> assoc_constraint(:sensor)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user