View Source EdgeDB.Object (EdgeDB v0.1.0)

An immutable representation of an object instance returned from a query.

EdgeDB.Object implements Access behavior to access properties by key.

iex(1)> {:ok, pid} = EdgeDB.start_link()
iex(2)> %EdgeDB.Object{} = object =
iex(2)>  EdgeDB.query_required_single!(pid, "
...(2)>   SELECT schema::ObjectType{
...(2)>     name
...(2)>   }
...(2)>   FILTER .name = 'std::Object'
...(2)>   LIMIT 1
...(2)>  ")
#EdgeDB.Object<name := "std::Object">
iex(3)> object[:name]
"std::Object"
iex(4)> object["name"]
"std::Object"

In EdgeDB, objects can have links to other objects or a set of objects. You can use the same syntax to access links values as for object properties. Links can also have their own properties (denoted as @<link_prop_name> in EdgeQL syntax). You can use the same property name as in the query to access them from the links.

iex(1)> {:ok, pid} = EdgeDB.start_link()
iex(2)> %EdgeDB.Object{} = object =
iex(2)>  EdgeDB.query_required_single!(pid, "
...(2)>   SELECT schema::Property {
...(2)>       name,
...(2)>       annotations: {
...(2)>         name,
...(2)>         @value
...(2)>       }
...(2)>   }
...(2)>   FILTER .name = 'listen_port' AND .source.name = 'cfg::Config'
...(2)>   LIMIT 1
...(2)>  ")
#EdgeDB.Object<name := "listen_port", annotations := #EdgeDB.Set<{#EdgeDB.Object<name := "cfg::system", @value := "true">}>>
iex(3)> annotations = object[:annotations]
#EdgeDB.Set<{#EdgeDB.Object<name := "cfg::system", @value := "true">}>
iex(4)> link = Enum.at(annotations, 0)
#EdgeDB.Object<name := "cfg::system", @value := "true">
iex(5)> link["@value"]
"true"

Link to this section Summary

Types

t()

An immutable representation of an object instance returned from a query.

UUID value.

Link to this section Types

Specs

t() :: %EdgeDB.Object{id: uuid() | nil}

An immutable representation of an object instance returned from a query.

Fields:

  • :id - a unique ID of the object instance in the database.

Specs

uuid() :: String.t()

UUID value.