The result of a TypeQL query.
TypeDB answers come in three shapes, and the driver gives each its own struct so you can pattern match on the one you expect:
TypeDB.Answer.Ok— the query produced no answers.define,undefine, and writes whose results were not requested.TypeDB.Answer.ConceptRows— amatch/insert/updatepipeline. Each row binds query variables to concepts.TypeDB.Answer.ConceptDocuments— afetchpipeline. Each document is plain decoded JSON, shaped by the query itself.
Every answer carries query_type (:read, :write or :schema), which is
what TypeDB determined the query to be — not what you asked for.
query = "match $p isa person; select $p;"
case TypeDB.query!(conn, "social", query, transaction_type: :read) do
%TypeDB.Answer.ConceptRows{rows: rows} -> length(rows)
%TypeDB.Answer.Ok{} -> 0
endConceptRows and ConceptDocuments are Enumerable, so they can be piped
straight into Enum and Stream. Select an attribute if you want values —
typed_value/2 on an entity answers nil, because an entity is a thing with
an identity rather than a value:
conn
|> TypeDB.query!("social", "match $p isa person, has name $name; select $name;",
transaction_type: :read)
|> Enum.map(&TypeDB.ConceptRow.typed_value(&1, "name"))
#=> ["Alice", "Bob"]
Summary
Functions
Returns the documents of a ConceptDocuments answer, or [] for any other.
Returns the query type TypeDB classified this query as.
Returns the rows of a ConceptRows answer, or [] for any other answer.
Returns the server-side warning attached to an answer, if any.
Types
@type query_type() :: :read | :write | :schema
What TypeDB classified the query as.
@type t() :: TypeDB.Answer.Ok.t() | TypeDB.Answer.ConceptRows.t() | TypeDB.Answer.ConceptDocuments.t()
Functions
Returns the documents of a ConceptDocuments answer, or [] for any other.
@spec query_type(t()) :: query_type()
Returns the query type TypeDB classified this query as.
@spec rows(t()) :: [TypeDB.ConceptRow.t()]
Returns the rows of a ConceptRows answer, or [] for any other answer.
Returns the server-side warning attached to an answer, if any.
TypeDB uses warnings for things like an answer set truncated by
answer_count_limit.