diplomat v0.3.1 Diplomat.Entity

Summary

Functions

Create a Diplomat.Entity from a Diplomat.Proto.Entity

Creates a new Diplomat.Entity with the given properties

Creates a new Diplomat.Entity with the given properties and Diplomat.Key

Extract a Diplomat.Entity’s properties as a map

Types

t()
t :: %Diplomat.Entity{key: Diplomat.Key.t, kind: String.t, properties: %{optional(String.t) => Diplomat.Value.t}}

Functions

extract_mutations(list, acc)
from_proto(entity)
from_proto(Diplomat.Proto.Entity.t) :: t

Create a Diplomat.Entity from a Diplomat.Proto.Entity

insert(entity)
new(props)
new(%{}) :: t

Creates a new Diplomat.Entity with the given properties.

Instead of building a Diplomat.Enity struct manually, new is the way you should create your entities. new wraps and nests properties correctly, and ensures that your entities have a valid Key (among other things).

new(props, key)
new(%{}, Diplomat.Key.t) :: t

Creates a new Diplomat.Entity with the given properties and Diplomat.Key

new(props, kind \\ nil, id \\ nil)
properties(entity)
properties(t) :: %{}

Extract a Diplomat.Entity’s properties as a map.

The properties are stored on the struct as a map string keys and Diplomat.Value values. This function will allow you to extract the properties as a map with string keys and Elixir built-in values.

For example, creating an Entity looks like the following:

iex> entity = Entity.new(%{"hello" => "world"})
# =>   %Diplomat.Entity{key: nil, kind: nil,
#         properties: %{"hello" => %Diplomat.Value{value: "world"}}}

Diplomat.Entity.properties/1 allows you to extract those properties to get the following: %{"hello" => "world"}

upsert(entity)