The concepts TypeDB returns inside conceptRows answers.
Every entry in a row is one of:
| Struct | TypeQL | Notes |
|---|---|---|
TypeDB.Concept.Entity | an entity instance | iid, optional type |
TypeDB.Concept.Relation | a relation instance | iid, optional type |
TypeDB.Concept.Attribute | an attribute instance | iid, value, value_type, optional type |
TypeDB.Concept.Value | a computed value | value, value_type |
TypeDB.Concept.EntityType | entity type | label |
TypeDB.Concept.RelationType | relation type | label |
TypeDB.Concept.AttributeType | attribute type | label, optional value_type |
TypeDB.Concept.RoleType | a relation role | label |
nil | an unbound optional variable | |
| a list | a list-valued variable | elements are concepts |
type is nil when the query ran with include_instance_types: false.
Values
value holds the value exactly as it came over the wire, which is what the
HTTP API defines: JSON primitives for boolean, integer, double and
string, and strings for decimal, date, datetime, datetime-tz and
duration.
Use typed_value/1 to convert to native Elixir terms:
iex> attr = %TypeDB.Concept.Attribute{iid: "0x1", value: "2024-03-01", value_type: "date"}
iex> TypeDB.Concept.typed_value(attr)
~D[2024-03-01]Conversion never loses information: datetime-tz and duration become
TypeDB.DateTimeTZ and TypeDB.Duration structs, which keep the original
wire form alongside the parsed fields.
Summary
Types
What kind of thing a concept is, in one atom.
A row entry: a concept, an unbound variable, or a list of concepts.
Functions
Casts a wire value given its TypeDB value type name.
What kind of thing a concept is.
Decodes one wire-format row entry into concept structs.
Returns the iid of an instance, or nil for types and values.
Whether the concept is data rather than schema.
Returns the label of a type, or of the type of an instance when it was included.
Whether the concept is a type.
Returns the value converted to a native Elixir term.
Returns the wire-format value of an attribute or value concept, nil otherwise.
Whether the concept is a bare value — a computed one, belonging to no instance.
Types
@type category() ::
:entity
| :relation
| :attribute
| :entity_type
| :relation_type
| :attribute_type
| :role_type
| :value
What kind of thing a concept is, in one atom.
The same eight the protocol distinguishes, spelled the way Elixir spells
atoms — :entity_type, not :entityType.
A row entry: a concept, an unbound variable, or a list of concepts.
@type instance() :: TypeDB.Concept.Entity.t() | TypeDB.Concept.Relation.t() | TypeDB.Concept.Attribute.t()
@type t() :: instance() | type() | TypeDB.Concept.Value.t()
@type type() :: TypeDB.Concept.EntityType.t() | TypeDB.Concept.RelationType.t() | TypeDB.Concept.AttributeType.t() | TypeDB.Concept.RoleType.t()
Functions
Casts a wire value given its TypeDB value type name.
What kind of thing a concept is.
The counterpart of Rust's Concept::get_category, and the reason it is worth
having in a language with pattern matching: a case on this is one line per
branch, where matching the structs means knowing all eight module names.
iex> TypeDB.Concept.category(%TypeDB.Concept.Entity{iid: "0x0", type: nil})
:entity
iex> TypeDB.Concept.category(%TypeDB.Concept.AttributeType{label: "name"})
:attribute_typeRust's other thirty-odd accessors are deliberately not here. try_get_integer
and its dozen siblings say in a method what typed_value/1 says once, and
is_entity is match?(%Entity{}, concept) — a predicate that reads worse
than the match it wraps. What survives the translation is this, plus the three
predicates below, which answer questions the struct name alone does not.
Decodes one wire-format row entry into concept structs.
Raises TypeDB.Error with kind: :decode when the payload does not look like
anything the HTTP API can produce.
Returns the iid of an instance, or nil for types and values.
Whether the concept is data rather than schema.
iex> TypeDB.Concept.instance?(%TypeDB.Concept.Entity{iid: "0x0", type: nil})
true
iex> TypeDB.Concept.instance?(%TypeDB.Concept.EntityType{label: "person"})
false
Returns the label of a type, or of the type of an instance when it was included.
Whether the concept is a type.
iex> TypeDB.Concept.type?(%TypeDB.Concept.RoleType{label: "friendship:friend"})
true
Returns the value converted to a native Elixir term.
boolean→booleaninteger→integerdouble→floatstring→String.t()decimal→Decimal.t()when the optionalDecimallibrary is loaded, otherwise a string. TypeDB renders decimals with TypeQL's literal suffix ("12.345dec"), which is stripped either way — the value differs in type whenDecimalis absent, not in content. The suffix survives inTypeDB.Concept.value/1, which is the raw wire valuedate→Date.t()datetime→NaiveDateTime.t()datetime-tz→TypeDB.DateTimeTZ.t()duration→TypeDB.Duration.t()
Values that cannot be parsed are returned unchanged rather than raising, so a future TypeDB value type never breaks a running application.
Returns the wire-format value of an attribute or value concept, nil otherwise.
Whether the concept is a bare value — a computed one, belonging to no instance.
iex> TypeDB.Concept.value?(%TypeDB.Concept.Value{value: 3, value_type: "integer"})
trueAn attribute is not one: it has a value and is also a thing in the database.
value/1 and typed_value/1 read both.