c3p0 v0.3.1 C3P0.ID protocol View Source
Formalizes fetching the ID from data.
For maps the keys id, "id" are considered id fields and guid, "guid" are considered guid fields.
When requesting a guid, if one cannot be found by default it will fall back to the id.
Using with your own structs
By default your own structs will behave the same way as a map. However if you need to redefine which field should be considered the id/guid fields you'll need to derive the protocol.
defmodule MyStruct do
@derive {C3P0.ID, id_field: :token, guid_field: :arn}
defstruct [:token, :arn, :name]
end
Link to this section Summary
Link to this section Types
Link to this section Functions
Find a global id for a piece of data
Find the id of a piece of data