FatEcto v0.5.0 SanitizeRecord View Source

This module sanitize the response by removing structs that are not loaded alognwith meta. It supports lists of maps, tuples and map.

 use FatUtils.FatRecord, otp_app: :app_name, encoder_library: encode_library

Link to this section Summary

Link to this section Functions

Link to this function

put_map_value_conditionally(data_map, field, value)

View Source
Link to this function

put_value(data_map, field, value)

View Source

Sanitize the records.

Parameters

  • record/records - List of maps, tuple or a map.

Example

iex> record = FatEcto.Repo.insert!(%FatEcto.FatDoctor{name: "test", designation: "doctor", phone: "12345", address: "123 Hampton Road"})
iex> sanitized = Elixir.SanitizeRecord.sanitize(record)
iex> Map.drop(sanitized, [:id])
%{
    address: "123 Hampton Road",
    designation: "doctor",
    email: nil,
    end_date: nil,
    experience_years: nil,
    name: "test",
    phone: "12345",
    rating: nil,
    start_date: nil
  }
Link to this function

sanitize_map_iteratively(record)

View Source