Officially out now: The TypeDB 3.0 Roadmap

C# driver API reference

Connection

Drivers

Package: TypeDB.Driver

CloudDriver

static ITypeDBDriver CloudDriver(string address, TypeDBCredential credential)

Open a TypeDB Driver to a TypeDB Cloud server available at the provided address, using the provided credential.

Input parameters
Name Description Type

address

The address of the TypeDB server

string

credential

The credential to connect with

TypeDBCredential

Returns

ITypeDBDriver

Code examples
Drivers.CloudDriver(address, credential);

CloudDriver

static ITypeDBDriver CloudDriver(ICollection< string > addresses, TypeDBCredential credential)

Open a TypeDB Driver to TypeDB Cloud server(s) available at the provided addresses, using the provided credential.

Input parameters
Name Description Type

addresses

The address(es) of the TypeDB server(s) or translation map from addresses to be used by the driver for connection to addresses received from the TypeDB server(s)

ICollection< string >

credential

The credential to connect with

TypeDBCredential

Returns

ITypeDBDriver

Code examples
Drivers.CloudDriver(addresses, credential);

CoreDriver

static ITypeDBDriver CoreDriver(string address)

Open a TypeDB Driver to a TypeDB Core server available at the provided address.

Input parameters
Name Description Type

address

The address of the TypeDB server

string

Returns

ITypeDBDriver

Code examples
Drivers.CoreDriver(address);

ITypeDBDriver

Package: TypeDB.Driver.Api

Close

void Close()

Closes the driver. Before instantiating a new driver, the driver that’s currently open should first be closed.

Returns

void

Code examples
driver.Close();

Databases

IDatabaseManager TypeDB.Driver.Api.ITypeDBDriver.Databases

The IDatabaseManager for this connection, providing access to database management methods.

Returns

IDatabaseManager

Code examples
driver.Databases;

GetCurrentUser

IUser GetCurrentUser()

Returns the logged-in user for the connection. Only for TypeDB Cloud.

Returns

IUser

Code examples
driver.GetCurrentUser();

IsOpen

bool IsOpen()

Checks whether this connection is presently open.

Returns

bool

Code examples
driver.IsOpen();

Session

ITypeDBSession Session(string database, SessionType type)

Opens a session to the given database with default options.

See also

ITypeDBDriver::Session(string, SessionType, TypeDBOptions);
Returns

ITypeDBSession

Session

ITypeDBSession Session(string database, SessionType type, TypeDBOptions options)

Opens a communication tunnel (session) to the given database on the running TypeDB server. For more information on the methods, available with sessions, see the ITypeDBSession section.

Input parameters
Name Description Type

database

The name of the database with which the session connects

string

type

The type of session to be created (Data or Schema)

SessionType

options

TypeDBOptions for the session

TypeDBOptions

Returns

ITypeDBSession

Code examples
driver.Session(database, sessionType, options);

Users

IUserManager TypeDB.Driver.Api.ITypeDBDriver.Users

The UserManager instance for this connection, providing access to user management methods. Only for TypeDB Cloud.

Returns

IUserManager

Code examples
driver.Users;

TypeDBCredential

Package: TypeDB.Driver.Api

User credentials and TLS encryption settings for connecting to TypeDB Cloud.

Examples
// Creates a credential as above, but the connection will be made over TLS.
TypeDBCredential credential = new TypeDBCredential(username, password, true);

// Creates a credential as above, but TLS will use the specified CA to authenticate server certificates.
TypeDBCredential credential = new TypeDBCredential(username, password, Environment.GetEnvironmentVariable("ROOT_CA")!);

TypeDBCredential

TypeDBCredential(string username, string password, bool tlsEnabled)
Input parameters
Name Description Type

username

The name of the user to connect as

string

password

The password for the user

string

tlsEnabled

Specify whether the connection to TypeDB Cloud must be done over TLS

bool

Returns

TypeDBCredential

TypeDBCredential

TypeDBCredential(string username, string password, string? tlsRootCAPath)
Input parameters
Name Description Type

username

The name of the user to connect as

string

password

The password for the user

string

tlsRootCAPath

Path to the CA certificate to use for authenticating server certificates

string?

Returns

TypeDBCredential

IDatabaseManager

Package: TypeDB.Driver.Api

Provides access to all database management methods.

Contains

bool Contains(string name)

Checks if a database with the given name exists.

Input parameters
Name Description Type

name

The database name to be checked

string

Returns

bool

Code examples
driver.Databases.Contains(name);

Create

void Create(string name)

Create a database with the given name.

Input parameters
Name Description Type

name

The name of the database to be created

string

Returns

void

Code examples
driver.Databases.Create(name);

Get

IDatabase Get(string name)

Retrieve the database with the given name.

Input parameters
Name Description Type

name

The name of the database to retrieve

string

Returns

IDatabase

Code examples
driver.Databases.Get(name);

GetAll

IList< IDatabase > GetAll()

Retrieves all databases present on the TypeDB server.

Returns

IList< IDatabase >

Code examples
driver.Databases.GetAll();

IDatabase

Package: TypeDB.Driver.Api

Delete

void Delete()

Deletes this database.

Returns

void

Code examples
database.Delete();

GetReplicas

ISet< IReplica > GetReplicas()

Set of Replica instances for this database. Only works in TypeDB Cloud

Returns

ISet< IReplica >

Code examples
database.GetReplicas();

GetRuleSchema

string GetRuleSchema()

The rules in the schema as a valid TypeQL define query string.

Returns

string

Code examples
database.GetRuleSchema();

GetSchema

string GetSchema()

A full schema text as a valid TypeQL define query string.

Returns

string

Code examples
database.GetSchema();

GetTypeSchema

string GetTypeSchema()

The types in the schema as a valid TypeQL define query string.

Returns

string

Code examples
database.GetTypeSchema();

Name

string TypeDB.Driver.Api.IDatabase.Name

The database name as a string.

Returns

string

Code examples
database.Name;

PreferredReplica

IReplica? TypeDB.Driver.Api.IDatabase.PreferredReplica

Returns the preferred replica for this database. Operations which can be run on any replica will prefer to use this replica. Only works in TypeDB Cloud

Returns

IReplica?

Code examples
database.PreferredReplica;

PrimaryReplica

IReplica? TypeDB.Driver.Api.IDatabase.PrimaryReplica

Returns the primary replica for this database. Only works in TypeDB Cloud

Returns

IReplica?

Code examples
database.PrimaryReplica;

IReplica

Package: TypeDB.Driver.Api.IDatabase

The metadata and state of an individual raft replica of a database.

IsPreferred

bool IsPreferred()

Checks whether this is the preferred replica of the raft cluster. If true, Operations which can be run on any replica will prefer to use this replica.

Returns

bool

IsPrimary

bool IsPrimary()

Checks whether this is the primary replica of the raft cluster.

Returns

bool

Server

string TypeDB.Driver.Api.IDatabase.IReplica.Server

The server hosting this replica.

Returns

string

Term

long TypeDB.Driver.Api.IDatabase.IReplica.Term

The raft protocol ‘term’ of this replica.

Returns

long

IUserManager

Package: TypeDB.Driver.Api

Provides access to all user management methods.

Contains

bool Contains(string username)

Checks if a user with the given name exists.

Input parameters
Name Description Type

username

The user name to be checked

string

Returns

bool

Code examples
driver.Users.Contains(username);

Create

void Create(string username, string password)

Creates a user with the given name & password.

Input parameters
Name Description Type

username

The name of the user to be created

string

password

The password of the user to be created

string

Returns

void

Code examples
driver.Users.Create(username, password);

Delete

void Delete(string username)

Deletes a user with the given name.

Input parameters
Name Description Type

username

The name of the user to be deleted

string

Returns

void

Code examples
driver.Users.Delete(username);

Get

IUser? Get(string username)

Retrieves a user with the given name.

Input parameters
Name Description Type

username

The name of the user to retrieve

string

Returns

IUser?

Code examples
driver.Users.Get(username);

GetAll

ISet< IUser > GetAll()

Retrieves all users which exist on the TypeDB server.

Returns

ISet< IUser >

Code examples
driver.Users.GetAll();

SetPassword

void SetPassword(string username, string password)

Sets a new password for a user. This operation can only be performed by administrators.

Input parameters
Name Description Type

username

The name of the user to set the password of

string

password

The new password

string

Returns

void

Code examples
driver.Users.SetPassword(username, password);

IUser

Package: TypeDB.Driver.Api

TypeDB user information

PasswordExpirySeconds

long? TypeDB.Driver.Api.IUser.PasswordExpirySeconds

Returns the number of seconds remaining till this user’s current password expires.

Returns

long?

UpdatePassword

void UpdatePassword(string passwordOld, string passwordNew)

Updates the password for this user.

Input parameters
Name Description Type

passwordOld

The current password of this user

string

passwordNew

The new password

string

Returns

void

Username

string TypeDB.Driver.Api.IUser.Username

Returns the name of this user.

Returns

string

Session

ITypeDBSession

Package: TypeDB.Driver.Api

Close

void Close()

Closes the session. Before opening a new session, the session currently open should first be closed.

Returns

void

Code examples
session.Close();

DatabaseName

string TypeDB.Driver.Api.ITypeDBSession.DatabaseName

Returns the name of the database of the session.

Returns

string

Code examples
session.DatabaseName;

IsOpen

bool IsOpen()

Checks whether this session is open.

Returns

bool

Code examples
session.IsOpen();

OnClose

void OnClose(Action function)

Registers a callback function which will be executed when this session is closed.

Input parameters
Name Description Type

function

The callback function.

Action

Returns

void

Code examples
session.OnClose(function);

OnReopen

void OnReopen(Action function)

Registers a callback function which will be executed when this session is reopened. A session may be closed if it times out, or loses the connection to the database. In such situations, the session is reopened automatically when opening a new transaction.

Input parameters
Name Description Type

function

The callback function.

Action

Returns

void

Code examples
session.OnReopen(function);

Options

TypeDBOptions TypeDB.Driver.Api.ITypeDBSession.Options

Gets the options for the session.

Returns

TypeDBOptions

Code examples
session.Options;

Transaction

ITypeDBTransaction Transaction(TransactionType type)

Opens a transaction on the database connected to the session with default options.

See also

ITypeDBSession::Transaction(TransactionType, TypeDBOptions)
Returns

ITypeDBTransaction

Transaction

ITypeDBTransaction Transaction(TransactionType type, TypeDBOptions options)

Opens a transaction to perform read or write queries on the database connected to the session.

Input parameters
Name Description Type

type

The type of transaction to be created (Read or Write)

TransactionType

options

Options for the session

TypeDBOptions

Returns

ITypeDBTransaction

Code examples
session.Transaction(transactionType, options);

Type

SessionType TypeDB.Driver.Api.ITypeDBSession.Type

The current session’s type (Schema or Data).

Returns

SessionType

Code examples
session.Type;

SessionType

Package: TypeDB.Driver.Api

Used to specify the type of the session.

Examples
driver.Session(database, SessionType.Schema);
Enum constants
Name

Data

Schema

TypeDBOptions

Package: TypeDB.Driver.Api

TypeDB session and transaction options. TypeDBOptions object can be used to override the default server behaviour.

Explain

bool? Explain()

Returns the value set for the explanation in this TypeDBOptions object. If set to true, explanations for queries are enabled.

Returns

bool?

Code examples
options.Explain();

Explain

TypeDBOptions Explain(bool explain)

Explicitly enables or disables explanations. If set to true, enables explanations for queries. Only affects read transactions.

Input parameters
Name Description Type

explain

Explicitly enable or disable explanations

bool

Returns

TypeDBOptions

Code examples
options.Explain(explain);

Infer

bool? Infer()

Returns the value set for the inference in this TypeDBOptions object.

Returns

bool?

Code examples
options.Infer();

Infer

TypeDBOptions Infer(bool infer)

Explicitly enables or disables inference. Only settable at transaction level and above. Only affects read transactions.

Input parameters
Name Description Type

infer

Explicitly enable or disable inference

bool

Returns

TypeDBOptions

Code examples
options.Infer(infer);

Parallel

bool? Parallel()

Returns the value set for the parallel execution in this TypeDBOptions object. If set to true, the server uses parallel instead of single-threaded execution.

Returns

bool?

Code examples
options.Parallel();

Parallel

TypeDBOptions Parallel(bool parallel)

Explicitly enables or disables parallel execution. If set to true, the server uses parallel instead of single-threaded execution.

Input parameters
Name Description Type

parallel

Explicitly enable or disable parallel execution

bool

Returns

TypeDBOptions

Code examples
options.Parallel(parallel);

Prefetch

bool? Prefetch()

Returns the value set for the prefetching in this TypeDBOptions object. If set to true, the first batch of answers is streamed to the driver even without an explicit request for it.

Returns

bool?

Code examples
options.Prefetch();

Prefetch

TypeDBOptions Prefetch(bool prefetch)

Explicitly enables or disables prefetching. If set to true, the first batch of answers is streamed to the driver even without an explicit request for it.

Input parameters
Name Description Type

prefetch

Explicitly enable or disable prefetching

bool

Returns

TypeDBOptions

Code examples
options.Prefetch(prefetch);

PrefetchSize

int? PrefetchSize()

Returns the value set for the prefetch size in this TypeDBOptions object. If set, specifies a guideline number of answers that the server should send before the driver issues a fresh request.

Returns

int?

Code examples
options.PrefetchSize();

PrefetchSize

TypeDBOptions PrefetchSize(int prefetchSize)

Explicitly sets a prefetch size. If set, specifies a guideline number of answers that the server should send before the driver issues a fresh request.

Input parameters
Name Description Type

prefetchSize

Number of answers that the server should send before the driver issues a fresh request

int

Returns

TypeDBOptions

Code examples
options.PrefetchSize(prefetchSize);

ReadAnyReplica

bool? ReadAnyReplica()

Returns the value set for reading data from any replica in this TypeDBOptions object. If set to True, enables reading data from any replica, potentially boosting read throughput.

Returns

bool?

Code examples
options.ReadAnyReplica();

ReadAnyReplica

TypeDBOptions ReadAnyReplica(bool readAnyReplica)

Explicitly enables or disables reading data from any replica. If set to True, enables reading data from any replica, potentially boosting read throughput. Only settable in TypeDB Cloud.

Input parameters
Name Description Type

readAnyReplica

Explicitly enable or disable reading data from any replica

bool

Returns

TypeDBOptions

Code examples
options.ReadAnyReplica(readAnyReplica);

SchemaLockAcquireTimeoutMillis

int? SchemaLockAcquireTimeoutMillis()

Returns the value set for the schema lock acquire timeout in this TypeDBOptions object. If set, specifies how long the driver should wait if opening a session or transaction is blocked by a schema write lock.

Returns

int?

Code examples
options.SchemaLockAcquireTimeoutMillis();

SchemaLockAcquireTimeoutMillis

TypeDBOptions SchemaLockAcquireTimeoutMillis(int schemaLockAcquireTimeoutMillis)

Explicitly sets schema lock acquire timeout. If set, specifies how long the driver should wait if opening a session or transaction is blocked by a schema write lock.

Input parameters
Name Description Type

schemaLockAcquireTimeoutMillis

How long the driver should wait if opening a session or transaction is blocked by a schema write lock.

int

Returns

TypeDBOptions

Code examples
options.SchemaLockAcquireTimeoutMillis(schemaLockAcquireTimeoutMillis);

SessionIdleTimeoutMillis

int? SessionIdleTimeoutMillis()

Returns the value set for the session idle timeout in this TypeDBOptions object. If set, specifies a timeout that allows the server to close sessions if the driver terminates or becomes unresponsive.

Returns

int?

Code examples
options.SessionIdleTimeoutMillis();

SessionIdleTimeoutMillis

TypeDBOptions SessionIdleTimeoutMillis(int sessionIdleTimeoutMillis)

Explicitly sets a session idle timeout. If set, specifies a timeout that allows the server to close sessions if the driver terminates or becomes unresponsive.

Input parameters
Name Description Type

sessionIdleTimeoutMillis

timeout that allows the server to close sessions if the driver terminates or becomes unresponsive.

int

Returns

TypeDBOptions

Code examples
options.SessionIdleTimeoutMillis(sessionIdleTimeoutMillis);

TraceInference

bool? TraceInference()

Returns the value set for reasoning tracing in this TypeDBOptions object. If set to true, reasoning tracing graphs are output in the logging directory.

Returns

bool?

Code examples
options.TraceInference();

TraceInference

TypeDBOptions TraceInference(bool traceInference)

Explicitly enables or disables reasoning tracing. If set to true, reasoning tracing graphs are output in the logging directory. Should be used with parallel = False.

Input parameters
Name Description Type

traceInference

Explicitly enable or disable reasoning tracing

bool

Returns

TypeDBOptions

Code examples
options.TraceInference(traceInference);

TransactionTimeoutMillis

int? TransactionTimeoutMillis()

Returns the value set for the transaction timeout in this TypeDBOptions object. If set, specifies a timeout for killing transactions automatically, preventing memory leaks in unclosed transactions.

Returns

int?

Code examples
options.TransactionTimeoutMillis();

TransactionTimeoutMillis

TypeDBOptions TransactionTimeoutMillis(int transactionTimeoutMillis)

Explicitly set a transaction timeout. If set, specifies a timeout for killing transactions automatically, preventing memory leaks in unclosed transactions.

Input parameters
Name Description Type

transactionTimeoutMillis

Timeout for killing transactions automatically.

int

Returns

TypeDBOptions

Code examples
options.TransactionTimeoutMillis(transactionTimeoutMillis);

TypeDBOptions

TypeDBOptions()

Produces a new TypeDBOptions object.

Returns

TypeDBOptions

Code examples
TypeDBOptions options = TypeDBOptions();

Transaction

ITypeDBTransaction

Package: TypeDB.Driver.Api

Close

void Close()

Closes the transaction.

Returns

void

Code examples
transaction.Close();

Commit

void Commit()

Commits the changes made via this transaction to the TypeDB database. Whether or not the transaction is committed successfully, it gets closed after the commit call.

Returns

void

Code examples
transaction.Commit();

Concepts

IConceptManager TypeDB.Driver.Api.ITypeDBTransaction.Concepts

The ConceptManager for this transaction, providing access to all Concept API methods.

Returns

IConceptManager

Code examples
transaction.Concepts;

IsOpen

bool IsOpen()

Checks whether this transaction is open.

Returns

bool

Code examples
transaction.IsOpen();

Logic

ILogicManager TypeDB.Driver.Api.ITypeDBTransaction.Logic

The LogicManager for this Transaction, providing access to all Concept API - Logic methods.

Returns

ILogicManager

Code examples
transaction.Logic;

OnClose

void OnClose(Action< Exception > function)

Registers a callback function which will be executed when this transaction is closed.

Input parameters
Name Description Type

function

The callback function.

Action< Exception >

Returns

void

Code examples
transaction.OnClose(function);

Options

TypeDBOptions TypeDB.Driver.Api.ITypeDBTransaction.Options

The options for the transaction.

Returns

TypeDBOptions

Code examples
transaction.Options;

Query

IQueryManager TypeDB.Driver.Api.ITypeDBTransaction.Query

The`QueryManager` for this Transaction, from which any TypeQL query can be executed.

Returns

IQueryManager

Code examples
transaction.Query;

Rollback

void Rollback()

Rolls back the uncommitted changes made via this transaction.

Returns

void

Code examples
transaction.Rollback();

Type

TransactionType TypeDB.Driver.Api.ITypeDBTransaction.Type

The transaction’s type (Read or Write).

Returns

TransactionType

Code examples
transaction.Type;

TransactionType

Package: TypeDB.Driver.Api

Used to specify the type of transaction.

Examples
session.Transaction(TransactionType.Read);
Enum constants
Name

Read

Write

IQueryManager

Package: TypeDB.Driver.Api

Provides methods for executing TypeQL queries in the transaction.

Define

VoidPromise Define(string query)

Performs a TypeQL Define query with default options.

See also

IQueryManager::Define(string, TypeDBOptions)
Returns

VoidPromise

Define

VoidPromise Define(string query, TypeDBOptions options)

Performs a TypeQL Define query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Define query to be executed

string

options

Specify query options

TypeDBOptions

Returns

VoidPromise

Code examples
transaction.Query.Define(query, options).Resolve()

Delete

VoidPromise Delete(string query)

Performs a TypeQL Delete query with default options.

See also

IQueryManager::Delete(string, TypeDBOptions)
Returns

VoidPromise

Delete

VoidPromise Delete(string query, TypeDBOptions options)

Performs a TypeQL Delete query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Delete query to be executed

string

options

Specify query options

TypeDBOptions

Returns

VoidPromise

Code examples
transaction.Query.Delete(query, options).Resolve()

Explain

IEnumerable< IExplanation > IExplainable explainable)

Performs a TypeQL Explain query with default options.

See also

IQueryManager::Explain(IConceptMap.IExplainable, TypeDBOptions)
Returns

IEnumerable< IExplanation > IExplainable

Explain

IEnumerable< IExplanation > IExplainable explainable, TypeDBOptions options)

Performs a TypeQL Explain query in the transaction.

Input parameters
Name Description Type

explainable

The IExplainable to be explained

IEnumerable< IExplanation > IExplainable

options

Specify query options

TypeDBOptions

Returns

IEnumerable< IExplanation > IExplainable explainable, TypeDBOptions

Code examples
transaction.Query.Explain(explainable, options)

Fetch

IEnumerable< JObject > Fetch(string query)

Performs a TypeQL Fetch (Fetch) with default options.

See also

IQueryManager::Fetch(string, TypeDBOptions)
Returns

IEnumerable< JObject >

Fetch

IEnumerable< JObject > Fetch(string query, TypeDBOptions options)

Performs a TypeQL Fetch (Fetch) query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Fetch (Fetch) query to be executed

string

options

Specify query options

TypeDBOptions

Returns

IEnumerable< JObject >

Code examples
transaction.Query.Fetch(query, options)

Get

IEnumerable< IConceptMap > Get(string query)

Performs a TypeQL Get (Get) with default options.

See also

IQueryManager::Get(string, TypeDBOptions)
Returns

IEnumerable< IConceptMap >

Get

IEnumerable< IConceptMap > Get(string query, TypeDBOptions options)

Performs a TypeQL Get (Get) query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Get (Get) query to be executed

string

options

Specify query options

TypeDBOptions

Returns

IEnumerable< IConceptMap >

Code examples
transaction.Query.Get(query, options);

GetAggregate

Promise< IValue > GetAggregate(string query)

Performs a TypeQL Get Aggregate query with default options.

See also

IQueryManager::GetAggregate(string, TypeDBOptions)
Returns

Promise< IValue >

GetAggregate

Promise< IValue > GetAggregate(string query, TypeDBOptions options)

Performs a TypeQL Get Aggregate query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Get Aggregate query to be executed

string

options

Specify query options

TypeDBOptions

Returns

Promise< IValue >

Code examples
transaction.Query.GetAggregate(query, options).Resolve()

GetGroup

IEnumerable< IConceptMapGroup > GetGroup(string query)

Performs a TypeQL Get Group query with default options.

See also

IQueryManager::GetGroup(string, TypeDBOptions)
Returns

IEnumerable< IConceptMapGroup >

GetGroup

IEnumerable< IConceptMapGroup > GetGroup(string query, TypeDBOptions options)

Performs a TypeQL Get Group query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Get Group query to be executed

string

options

Specify query options

TypeDBOptions

Returns

IEnumerable< IConceptMapGroup >

Code examples
transaction.Query.GetGroup(query, options)

GetGroupAggregate

IEnumerable< IValueGroup > GetGroupAggregate(string query)

Performs a TypeQL Get Group Aggregate query with default options.

See also

IQueryManager::GetGroupAggregate(string, TypeDBOptions)
Returns

IEnumerable< IValueGroup >

GetGroupAggregate

IEnumerable< IValueGroup > GetGroupAggregate(string query, TypeDBOptions options)

Performs a TypeQL Get Group Aggregate query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Get Group Aggregate query to be executed

string

options

Specify query options

TypeDBOptions

Returns

IEnumerable< IValueGroup >

Code examples
transaction.Query.GetGroupAggregate(query, options)

Insert

IEnumerable< IConceptMap > Insert(string query)

Performs a TypeQL Insert query with default options.

See also

IQueryManager::Insert(string, TypeDBOptions)
Returns

IEnumerable< IConceptMap >

Insert

IEnumerable< IConceptMap > Insert(string query, TypeDBOptions options)

Performs a TypeQL Insert query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Insert query to be executed

string

options

Specify query options

TypeDBOptions

Returns

IEnumerable< IConceptMap >

Code examples
transaction.Query.Insert(query, options)

Undefine

VoidPromise Undefine(string query)

Performs a TypeQL Undefine query with default options.

See also

IQueryManager::Undefine(string, TypeDBOptions)
Returns

VoidPromise

Undefine

VoidPromise Undefine(string query, TypeDBOptions options)

Performs a TypeQL Undefine query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Undefine query to be executed

string

options

Specify query options

TypeDBOptions

Returns

VoidPromise

Code examples
transaction.Query.Undefine(query, options).Resolve()

Update

IEnumerable< IConceptMap > Update(string query)

Performs a TypeQL Update query with default options.

See also

IQueryManager::Update(string, TypeDBOptions)
Returns

IEnumerable< IConceptMap >

Update

IEnumerable< IConceptMap > Update(string query, TypeDBOptions options)

Performs a TypeQL Update query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Update query to be executed

string

options

Specify query options

TypeDBOptions

Returns

IEnumerable< IConceptMap >

Code examples
transaction.Query.Update(query, options)

Answer

IConceptMap

Package: TypeDB.Driver.Api

Contains a mapping of variables to concepts.

AllExplainables

IExplainables TypeDB.Driver.Api.IConceptMap.AllExplainables

Gets the IExplainables object for this IConceptMap, exposing which of the concepts in this IConceptMap are explainable.

Returns

IExplainables

Code examples
conceptMap.AllExplainables;

Get

IConcept Get(string variable)

Retrieves a concept for a given variable name.

Input parameters
Name Description Type

variable

The string representation of a variable

string

Returns

IConcept

Code examples
conceptMap.Get(variable);

GetConcepts

IEnumerable< IConcept > GetConcepts()

Returns a collection of all concepts in this IConceptMap.

Returns

IEnumerable< IConcept >

Code examples
conceptMap.GetConcepts();

GetMap

Dictionary< string, IConcept > GetMap()

Returns the inner Dictionary (Map as a common TypeDB term) where keys are query variables, and values are concepts.

Returns

Dictionary< string, IConcept >

Code examples
conceptMap.GetMap();

GetVariables

IEnumerable< string > GetVariables()

Returns a collection of all variables in this IConceptMap.

Returns

IEnumerable< string >

Code examples
conceptMap.GetVariables();

IConceptMapGroup

Package: TypeDB.Driver.Api

Contains an element of the group query result.

GetConceptMaps

IEnumerable< IConceptMap > GetConceptMaps()

Retrieves the IConceptMaps of the group.

Returns

IEnumerable< IConceptMap >

Code examples
conceptMapGroup.GetConceptMaps();

Owner

IConcept TypeDB.Driver.Api.IConceptMapGroup.Owner

Retrieves the concept that is the group owner.

Returns

IConcept

Code examples
conceptMapGroup.Owner;

IValueGroup

Package: TypeDB.Driver.Api

Contains an element of the group aggregate query result.

Owner

IConcept TypeDB.Driver.Api.IValueGroup.Owner

Retrieves the concept that is the group owner.

Returns

IConcept

Code examples
conceptMapGroup.Owner;

Value

IValue? TypeDB.Driver.Api.IValueGroup.Value

Retrieves the Value answer of the group.

Returns

IValue?

Code examples
valueGroup.Value;

IExplainables

Package: TypeDB.Driver.Api.IConceptMap

Contains explainable objects.

Attribute

IExplainable Attribute(string variable)

Retrieves the explainable attribute with the given variable name.

Input parameters
Name Description Type

variable

The string representation of a variable

string

Returns

IExplainable

Code examples
conceptMap.AllExplainables.Attribute(variable);

GetAttributes

IEnumerable< KeyValuePair< string, IExplainable > > GetAttributes()

Retrieves all of this IConceptMap’s explainable attributes.

Returns

IEnumerable< KeyValuePair< string, IExplainable > >

Code examples
conceptMap.AllExplainables.GetAttributes();

GetOwnerships

IEnumerable< KeyValuePair< KeyValuePair< string, string >, IExplainable > > GetOwnerships()

Retrieves all of this IConceptMap’s explainable ownerships.

Returns

IEnumerable< KeyValuePair< KeyValuePair< string, string >, IExplainable > >

Code examples
conceptMap.AllExplainables.GetOwnerships();

GetRelations

IEnumerable< KeyValuePair< string, IExplainable > > GetRelations()

Retrieves all of this IConceptMap’s explainable relations.

Returns

IEnumerable< KeyValuePair< string, IExplainable > >

Code examples
conceptMap.AllExplainables.GetRelations();

Ownership

IExplainable Ownership(string owner, string attribute)

Retrieves the explainable attribute ownership with the pair of (owner, attribute) variable names.

Input parameters
Name Description Type

owner

The string representation of the owner variable

string

attribute

The string representation of the attribute variable

string

Returns

IExplainable

Code examples
conceptMap.AllExplainables.Ownership(owner, attribute);

Relation

IExplainable Relation(string variable)

Retrieves the explainable relation with the given variable name.

Input parameters
Name Description Type

variable

The string representation of a variable

string

Returns

IExplainable

Code examples
conceptMap.AllExplainables.Relation(variable);

IExplainable

Package: TypeDB.Driver.Api.IConceptMap

Contains an explainable object.

Conjunction

string TypeDB.Driver.Api.IConceptMap.IExplainable.Conjunction

Retrieves the subquery of the original query that is actually being explained.

Returns

string

Code examples
explainable.Conjunction;

Id

long TypeDB.Driver.Api.IConceptMap.IExplainable.Id

Retrieves the unique ID that identifies this IExplainable.

Returns

long

Code examples
explainable.Id;

IExplanation

Package: TypeDB.Driver.Api

An explanation of which rule was used for inferring the explained concept, the condition of the rule, the conclusion of the rule, and the mapping of variables between the query and the rule’s conclusion.

Conclusion

IConceptMap TypeDB.Driver.Api.IExplanation.Conclusion

Retrieves the Conclusion for this Explanation.

Returns

IConceptMap

Code examples
explanation.Conclusion

Condition

IConceptMap TypeDB.Driver.Api.IExplanation.Condition

Retrieves the Condition for this Explanation.

Returns

IConceptMap

Code examples
explanation.Condition

GetQueryVariables

ISet< string > GetQueryVariables()

Retrieves the query variables for this Explanation.

Returns

ISet< string >

Code examples
explanation.GetQueryVariables()

QueryVariableMapping

ISet< string > QueryVariableMapping(string variable)

Retrieves the rule variables corresponding to the query variable var for this Explanation.

Input parameters
Name Description Type

variable

The query variable to map to rule variables.

string

Returns

ISet< string >

Code examples
explanation.VariableMapping(variable)

Rule

IRule TypeDB.Driver.Api.IExplanation.Rule

Retrieves the Rule for this Explanation.

Returns

IRule

Code examples
explanation.Rule;

Promise< T >

Package: TypeDB.Driver.Common

A Promise represents an asynchronous network operation.

The request it represents is performed immediately. The response is only retrieved once the Promise is Resolved.

Map< TFrom, TTo >

static Promise< TTo > TypeDB.Driver.Common.Promise< T >.Map< TFrom, TTo >(Func< TFrom? > resolver, Func< TFrom, TTo > selector)

Helper function to map promises.

Input parameters
Name Description Type

resolver

The function to wrap into the promise

Func< TFrom? >

selector

The mapping (like Select from Linq) function

Func< TFrom, TTo >

Returns

Promise< TTo >

Code examples
Promise<TFrom>.Map<TFrom, TTo>(resolver, selector);

Promise

Promise(Func< T? > resolver)

Promise constructor

Input parameters
Name Description Type

resolver

The function to wrap into the promise

Func< T? >

Returns

Promise

Code examples
new Promise(resolver);

Resolve

T? Resolve()

Retrieves the result of the Promise.

Returns

T?

Code examples
promise.Resolve();

VoidPromise

Package: TypeDB.Driver.Common

A VoidPromise represents a Promise without an operation’s result.

See also

Promise

Resolve

void Resolve()

Retrieves the result of the Promise.

Returns

void

Code examples
promise.Resolve();

VoidPromise

VoidPromise(Action resolver)

Promise constructor

Input parameters
Name Description Type

promise

The function to wrap into the promise

Returns

VoidPromise

Code examples
new Promise(action);

Concept

IConceptManager

Package: TypeDB.Driver.Api

Provides access for all Concept API methods.

GetAttribute

Promise< IAttribute > GetAttribute(string iid)

Retrieves an IAttribute by its iid.

Input parameters
Name Description Type

iid

The iid of the Attribute to retrieve.

string

Returns

Promise< IAttribute >

Code examples
transaction.Concepts.GetAttribute(iid).Resolve();

GetAttributeType

Promise< IAttributeType > GetAttributeType(string label)

Retrieves an IAttributeType by its label.

Input parameters
Name Description Type

label

The label of the AttributeType to retrieve.

string

Returns

Promise< IAttributeType >

Code examples
transaction.Concepts.GetAttributeType(label).Resolve();

GetEntity

Promise< IEntity > GetEntity(string iid)

Retrieves an IEntity by its iid.

Input parameters
Name Description Type

iid

The iid of the Entity to retrieve.

string

Returns

Promise< IEntity >

Code examples
transaction.Concepts.GetEntity(iid).Resolve();

GetEntityType

Promise< IEntityType > GetEntityType(string label)

Retrieves an IEntityType by its label.

Input parameters
Name Description Type

label

The label of the IEntityType to retrieve.

string

Returns

Promise< IEntityType >

Code examples
transaction.Concepts.GetEntityType(label).Resolve();

GetRelation

Promise< IRelation > GetRelation(string iid)

Retrieves a IRelation by its iid.

Input parameters
Name Description Type

iid

The iid of the Relation to retrieve.

string

Returns

Promise< IRelation >

Code examples
transaction.Concepts.GetRelation(iid).Resolve();

GetRelationType

Promise< IRelationType > GetRelationType(string label)

Retrieves a IRelationType by its label.

Input parameters
Name Description Type

label

The label of the IRelationType to retrieve.

string

Returns

Promise< IRelationType >

Code examples
transaction.Concepts.GetRelationType(label).Resolve();

GetSchemaExceptions

IList< TypeDBException > GetSchemaExceptions()

A list of all schema exceptions for the current transaction.

Returns

IList< TypeDBException >

Code examples
transaction.Concepts.GetSchemaExceptions();

PutAttributeType

Promise< IAttributeType > PutAttributeType(string label, IValue.ValueType valueType)

Creates a new IAttributeType if none exists with the given label, or retrieves the existing one.

Input parameters
Name Description Type

label

The label of the IAttributeType to create or retrieve.

string

valueType

The value type of the IAttributeType to create.

IValue​.ValueType

Returns

Promise< IAttributeType >

Code examples
await transaction.Concepts.PutAttributeType(label, valueType).Resolve();

PutEntityType

Promise< IEntityType > PutEntityType(string label)

Creates a new IEntityType if none exists with the given label, otherwise retrieves the existing one.

Input parameters
Name Description Type

label

The label of the IEntityType to create or retrieve.

string

Returns

Promise< IEntityType >

Code examples
transaction.Concepts.PutEntityType(label).Resolve();

PutRelationType

Promise< IRelationType > PutRelationType(string label)

Creates a new IRelationType if none exists with the given label, otherwise retrieves the existing one.

Input parameters
Name Description Type

label

The label of the IRelationType to create or retrieve.

string

Returns

Promise< IRelationType >

Code examples
transaction.Concepts.PutRelationType(label).Resolve();

RootAttributeType

IAttributeType TypeDB.Driver.Api.IConceptManager.RootAttributeType

The root IAttributeType, “attribute”.

Returns

IAttributeType

Code examples
transaction.Concepts.RootAttributeType;

RootEntityType

IEntityType TypeDB.Driver.Api.IConceptManager.RootEntityType

The root IEntityType, “entity”.

Returns

IEntityType

Code examples
transaction.Concepts.RootEntityType;

RootRelationType

IRelationType TypeDB.Driver.Api.IConceptManager.RootRelationType

The root IRelationType, “relation”.

Returns

IRelationType

Code examples
transaction.Concepts.RootRelationType;

IConcept

Package: TypeDB.Driver.Api

AsAttribute

IAttribute AsAttribute()

Casts the concept to IAttribute.

Implemented in TypeDB.Driver.Api.IAttribute.

Returns

IAttribute

Code examples
concept.AsAttribute();

AsAttributeType

IAttributeType AsAttributeType()

Casts the concept to IAttributeType.

Implemented in TypeDB.Driver.Api.IAttributeType.

Returns

IAttributeType

Code examples
concept.AsAttributeType();

AsEntity

IEntity AsEntity()

Casts the concept to IEntity.

Implemented in TypeDB.Driver.Api.IEntity.

Returns

IEntity

Code examples
concept.AsEntity();

AsEntityType

IEntityType AsEntityType()

Casts the concept to IEntityType.

Implemented in TypeDB.Driver.Api.IEntityType.

Returns

IEntityType

Code examples
concept.AsEntityType();

AsRelation

IRelation AsRelation()

Casts the concept to IRelation.

Implemented in TypeDB.Driver.Api.IRelation.

Returns

IRelation

Code examples
concept.AsRelation();

AsRelationType

IRelationType AsRelationType()

Casts the concept to IRelationType.

Implemented in TypeDB.Driver.Api.IRelationType.

Returns

IRelationType

Code examples
concept.AsRelationType();

AsRoleType

IRoleType AsRoleType()

Casts the concept to IRoleType.

Implemented in TypeDB.Driver.Api.IRoleType.

Returns

IRoleType

Code examples
concept.AsRoleType();

AsThing

IThing AsThing()

Casts the concept to IThing.

Implemented in TypeDB.Driver.Api.IThing.

Returns

IThing

Code examples
concept.AsThing();

AsThingType

IThingType AsThingType()

Casts the concept to IThingType.

Implemented in TypeDB.Driver.Api.IThingType.

Returns

IThingType

Code examples
concept.AsThingType();

AsType

IType AsType()

Casts the concept to IType.

Implemented in TypeDB.Driver.Api.IType.

Returns

IType

Code examples
concept.AsType();

AsValue

IValue AsValue()

Casts the concept to IValue.

Implemented in TypeDB.Driver.Api.IValue.

Returns

IValue

Code examples
concept.AsValue();

IsAttribute

bool IsAttribute()

Checks if the concept is an IAttribute.

Implemented in TypeDB.Driver.Api.IAttribute.

Returns

bool

Code examples
concept.IsAttribute();

IsAttributeType

bool IsAttributeType()

Checks if the concept is an IAttributeType.

Implemented in TypeDB.Driver.Api.IAttributeType.

Returns

bool

Code examples
concept.IsAttributeType();

IsEntity

bool IsEntity()

Checks if the concept is an IEntity.

Implemented in TypeDB.Driver.Api.IEntity.

Returns

bool

Code examples
concept.IsEntity();

IsEntityType

bool IsEntityType()

Checks if the concept is an IEntityType.

Implemented in TypeDB.Driver.Api.IEntityType.

Returns

bool

Code examples
concept.IsEntityType();

IsRelation

bool IsRelation()

Checks if the concept is a IRelation.

Implemented in TypeDB.Driver.Api.IRelation.

Returns

bool

Code examples
concept.IsRelation();

IsRelationType

bool IsRelationType()

Checks if the concept is a IRelationType.

Implemented in TypeDB.Driver.Api.IRelationType.

Returns

bool

Code examples
concept.IsRelationType();

IsRoleType

bool IsRoleType()

Checks if the concept is a IRoleType.

Implemented in TypeDB.Driver.Api.IRoleType.

Returns

bool

Code examples
concept.IsRoleType();

IsThing

bool IsThing()

Checks if the concept is a IThing.

Implemented in TypeDB.Driver.Api.IThing.

Returns

bool

Code examples
concept.IsThing();

IsThingType

bool IsThingType()

Checks if the concept is a IThingType.

Implemented in TypeDB.Driver.Api.IThingType.

Returns

bool

Code examples
concept.IsThingType();

IsType

bool IsType()

Checks if the concept is a IType.

Implemented in TypeDB.Driver.Api.IType.

Returns

bool

Code examples
concept.IsType();

IsValue

bool IsValue()

Checks if the concept is a IValue.

Implemented in TypeDB.Driver.Api.IValue.

Returns

bool

Code examples
concept.IsValue();

Transitivity

Package: TypeDB.Driver.Api.IConcept

This class is used for specifying whether we need explicit or transitive subtyping, instances, etc.

Examples
attributeType.GetOwners(transaction, annotation, Explicit);
Enum constants
Name

Explicit

Transitive

Schema

IType

Package: TypeDB.Driver.Api

Supertypes:

  • TypeDB.Driver.Api.IConcept

AsType

IType IConcept. AsType()

Casts the concept to IType.

Implements TypeDB.Driver.Api.IConcept.

Returns

IType IConcept.

Code examples
concept.AsType();

Delete

VoidPromise Delete(ITypeDBTransaction transaction)

Deletes this type from the database.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

VoidPromise

Code examples
type.Delete(transaction).Resolve();

GetSubtypes

IEnumerable< IType > GetSubtypes(ITypeDBTransaction transaction)

Retrieves all direct and indirect subtypes of the type. Equivalent to GetSubtypes(transaction, Transitive)

See also

IType::GetSubtypes(ITypeDBTransaction, IConcept.Transitivity)
Returns

IEnumerable< IType >

GetSubtypes

IEnumerable< IType > GetSubtypes(ITypeDBTransaction transaction, IConcept.Transitivity transitivity)

Retrieves all direct and indirect (or direct only) subtypes of the type.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

transitivity

Transitive for direct and indirect subtypes, Explicit for direct subtypes only

IConcept​.Transitivity

Returns

IEnumerable< IType >

Code examples
type.GetSubtypes(transaction);
type.GetSubtypes(transaction, Explicit);

GetSupertype

Promise< IType > GetSupertype(ITypeDBTransaction transaction)

Retrieves the most immediate supertype of the type.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

Promise< IType >

Code examples
type.GetSupertype(transaction).Resolve();

GetSupertypes

IEnumerable< IType > GetSupertypes(ITypeDBTransaction transaction)

Retrieves all supertypes of the type.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

IEnumerable< IType >

Code examples
type.GetSupertypes(transaction);

IsAbstract

bool IsAbstract()

Checks if the type is prevented from having data instances (i.e., abstract).

Returns

bool

Code examples
type.IsAbstract();

IsDeleted

Promise< bool > IsDeleted(ITypeDBTransaction transaction)

Check if the concept has been deleted.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

Promise< bool >

Code examples
type.IsDeleted(transaction).Resolve();

IsRoot

bool IsRoot()

Checks if the type is a root type.

Returns

bool

Code examples
type.IsRoot();

IsType

bool IConcept. IsType()

Checks if the concept is a IType.

Implements TypeDB.Driver.Api.IConcept.

Returns

bool IConcept.

Code examples
concept.IsType();

Label

Label TypeDB.Driver.Api.IType.Label

The unique label of the type.

Returns

Label

Code examples
type.Label;

SetLabel

VoidPromise SetLabel(ITypeDBTransaction transaction, string label)

Renames the label of the type. The new label must remain unique.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

label

The new Label to be given to the type.

string

Returns

VoidPromise

Code examples
type.SetLabel(transaction, newLabel).Resolve();

IThingType

Package: TypeDB.Driver.Api

Supertypes:

  • TypeDB.Driver.Api.IType

  • TypeDB.Driver.Api.IConcept

AsThingType

IThingType IConcept. AsThingType()

Casts the concept to IThingType.

Implements TypeDB.Driver.Api.IConcept.

Returns

IThingType IConcept.

Code examples
concept.AsThingType();

GetInstances

IEnumerable< IThing > GetInstances(ITypeDBTransaction transaction)

Retrieves all IThing objects that are instances of this IThingType or its subtypes. Equivalent to GetInstances(transaction, Transitive)

See also

IThingType::GetInstances(ITypeDBTransaction, IConcept.Transitivity)
Returns

IEnumerable< IThing >

GetInstances

IEnumerable< IThing > GetInstances(ITypeDBTransaction transaction, IConcept.Transitivity transitivity)

Retrieves IThing objects that are instances of this exact IThingType, OR this IThingType and any of its subtypes

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

transitivity

Explicit for direct instances only, Transitive to include instances of subtypes

IConcept​.Transitivity

Returns

IEnumerable< IThing >

Code examples
thingType.GetInstances(transaction);
thingType.GetInstances(transaction, Explicit);

GetOwns

IEnumerable< IAttributeType > GetOwns(ITypeDBTransaction transaction)

Retrieves IAttributeType that the instances of this IThingType are allowed to own directly or via inheritance.

See also

IThingType::GetOwns(ITypeDBTransaction, IValue.ValueType, ICollection<Annotation>, IConcept.Transitivity)
Returns

IEnumerable< IAttributeType >

GetOwns

IEnumerable< IAttributeType > GetOwns(ITypeDBTransaction transaction, IValue.ValueType valueType)

Retrieves IAttributeType that the instances of this IThingType are allowed to own directly or via inheritance.

See also

IThingType::GetOwns(ITypeDBTransaction, IValue.ValueType, ICollection<Annotation>, IConcept.Transitivity)
Returns

IEnumerable< IAttributeType >

GetOwns

IEnumerable< IAttributeType > GetOwns(ITypeDBTransaction transaction, ICollection< Annotation > annotations)

Retrieves IAttributeType that the instances of this IThingType are allowed to own directly or via inheritance.

See also

IThingType::GetOwns(ITypeDBTransaction, IValue.ValueType, ICollection<Annotation>, IConcept.Transitivity)
Returns

IEnumerable< IAttributeType >

GetOwns

IEnumerable< IAttributeType > GetOwns(ITypeDBTransaction transaction, IValue.ValueType? valueType, ICollection< Annotation > annotations)

Retrieves IAttributeType that the instances of this IThingType are allowed to own directly or via inheritance.

See also

IThingType::GetOwns(ITypeDBTransaction, IValue.ValueType?, ICollection<Annotation>, IConcept.Transitivity)
Returns

IEnumerable< IAttributeType >

GetOwns

IEnumerable< IAttributeType > GetOwns(ITypeDBTransaction transaction, IConcept.Transitivity transitivity)

Retrieves IAttributeType that the instances of this IThingType are allowed to own directly or via inheritance.

See also

IThingType::GetOwns(ITypeDBTransaction, IValue.ValueType, ICollection<Annotation>, IConcept.Transitivity)
Returns

IEnumerable< IAttributeType >

GetOwns

IEnumerable< IAttributeType > GetOwns(ITypeDBTransaction transaction, IValue.ValueType? valueType, IConcept.Transitivity transitivity)

Retrieves IAttributeType that the instances of this IThingType are allowed to own directly or via inheritance.

See also

IThingType::GetOwns(ITypeDBTransaction, IValue.ValueType?, ICollection<Annotation>, IConcept.Transitivity)
Returns

IEnumerable< IAttributeType >

GetOwns

IEnumerable< IAttributeType > GetOwns(ITypeDBTransaction transaction, ICollection< Annotation > annotations, IConcept.Transitivity transitivity)

Retrieves IAttributeType that the instances of this IThingType are allowed to own directly or via inheritance.

See also

IThingType::GetOwns(ITypeDBTransaction, IValue.ValueType, ICollection<Annotation>, IConcept.Transitivity)
Returns

IEnumerable< IAttributeType >

GetOwns

IEnumerable< IAttributeType > GetOwns(ITypeDBTransaction transaction, IValue.ValueType? valueType, ICollection< Annotation > annotations, IConcept.Transitivity transitivity)

Retrieves IAttributeType that the instances of this IThingType are allowed to own directly or via inheritance.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

valueType

If specified, only attribute types of this ValueType will be retrieved.

IValue​.ValueType?

transitivity

Transitive for direct and inherited ownership, Explicit for direct ownership only

IConcept​.Transitivity

annotations

Only retrieve attribute types owned with annotations.

ICollection< Annotation >

Returns

IEnumerable< IAttributeType >

Code examples
thingType.GetOwns(transaction);
thingType.GetOwns(transaction, valueType, Explicit, new []{NewKey()}));

GetOwnsOverridden

Promise< IAttributeType > GetOwnsOverridden(ITypeDBTransaction transaction, IAttributeType attributeType)

Retrieves an IAttributeType, ownership of which is overridden for this IThingType by a given IAttributeType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

attributeType

The IAttributeType that overrides requested IAttributeType

IAttributeType

Returns

Promise< IAttributeType >

Code examples
thingType.GetOwnsOverridden(transaction, attributeType).Resolve();

GetPlays

IEnumerable< IRoleType > GetPlays(ITypeDBTransaction transaction)

Retrieves all direct and inherited roles that are allowed to be played by the instances of this IThingType.

See also

IThingType::GetPlays(ITypeDBTransaction, IConcept.Transitivity)
Returns

IEnumerable< IRoleType >

GetPlays

IEnumerable< IRoleType > GetPlays(ITypeDBTransaction transaction, IConcept.Transitivity transitivity)

Retrieves all direct and inherited (or direct only) roles that are allowed to be played by the instances of this IThingType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

transitivity

transitivity: Transitive for direct and indirect playing, Explicit for direct playing only

IConcept​.Transitivity

Returns

IEnumerable< IRoleType >

Code examples
thingType.GetPlays(transaction).Resolve();
thingType.GetPlays(transaction, Explicit).Resolve();

GetPlaysOverridden

Promise< IRoleType > GetPlaysOverridden(ITypeDBTransaction transaction, IRoleType roleType)

Retrieves a IRoleType that is overridden by the given role_type for this IThingType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

roleType

The IRoleType that overrides an inherited role

IRoleType

Returns

Promise< IRoleType >

Code examples
thingType.GetPlaysOverridden(transaction, roleType).Resolve();

GetSyntax

Promise< string > GetSyntax(ITypeDBTransaction transaction)

Produces a pattern for creating this IThingType in a define query.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

Promise< string >

Code examples
thingType.GetSyntax(transaction).Resolve();

IsThingType

bool IConcept. IsThingType()

Checks if the concept is a IThingType.

Implements TypeDB.Driver.Api.IConcept.

Returns

bool IConcept.

Code examples
concept.IsThingType();

SetAbstract

VoidPromise SetAbstract(ITypeDBTransaction transaction)

Set a IThingType to be abstract, meaning it cannot have instances.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

VoidPromise

Code examples
thingType.SetAbstract(transaction).Resolve();

SetOwns

VoidPromise SetOwns(ITypeDBTransaction transaction, IAttributeType attributeType, IAttributeType? overriddenType, ICollection< Annotation > annotations)

Allows the instances of this IThingType to own the given IAttributeType. Optionally, overriding a previously declared ownership. Optionally, adds annotations to the ownership.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

attributeType

The IAttributeType to be owned by the instances of this type.

IAttributeType

overriddenType

The IAttributeType that this attribute ownership overrides, if applicable.

IAttributeType?

annotations

Adds annotations to the ownership.

ICollection< Annotation >

Returns

VoidPromise

Code examples
thingType.SetOwns(transaction, attributeType).Resolve();
thingType.SetOwns(transaction, attributeType, overriddenType, new []{NewKey()}).Resolve();

SetOwns

VoidPromise SetOwns(ITypeDBTransaction transaction, IAttributeType attributeType, IAttributeType overriddenType)

Allows the instances of this IThingType to own the given IAttributeType,

See also

IThingType::SetOwns(ITypeDBTransaction, IAttributeType, IAttributeType, Set)
Returns

VoidPromise

SetOwns

VoidPromise SetOwns(ITypeDBTransaction transaction, IAttributeType attributeType, ICollection< Annotation > annotations)

Allows the instances of this IThingType to own the given IAttributeType.

See also

IThingType::SetOwns(ITypeDBTransaction, IAttributeType, IAttributeType, Set)
Returns

VoidPromise

SetOwns

VoidPromise SetOwns(ITypeDBTransaction transaction, IAttributeType attributeType)

Allows the instances of this IThingType to own the given IAttributeType.

See also

IThingType::SetOwns(ITypeDBTransaction, IAttributeType, IAttributeType, Set)
Returns

VoidPromise

SetPlays

VoidPromise SetPlays(ITypeDBTransaction transaction, IRoleType roleType)

Allows the instances of this IThingType to play the given role.

See also

IThingType::SetPlays(ITypeDBTransaction, IRoleType, IRoleType)
Returns

VoidPromise

SetPlays

VoidPromise SetPlays(ITypeDBTransaction transaction, IRoleType roleType, IRoleType overriddenType)

Allows the instances of this IThingType to play the given role.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

roleType

The role to be played by the instances of this type

IRoleType

overriddenType

The role type that this role overrides, if applicable

IRoleType

Returns

VoidPromise

Code examples
thingType.SetPlays(transaction, roleType).Resolve();
thingType.SetPlays(transaction, roleType, overriddenType).Resolve();

UnsetAbstract

VoidPromise UnsetAbstract(ITypeDBTransaction transaction)

Set a IThingType to be non-abstract, meaning it can have instances.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

VoidPromise

Code examples
thingType.UnsetAbstract(transaction).Resolve();

UnsetOwns

VoidPromise UnsetOwns(ITypeDBTransaction transaction, IAttributeType attributeType)

Disallows the instances of this IThingType from owning the given IAttributeType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

attributeType

The IAttributeType to not be owned by the type.

IAttributeType

Returns

VoidPromise

Code examples
thingType.UnsetOwns(transaction, attributeType).Resolve();

UnsetPlays

VoidPromise UnsetPlays(ITypeDBTransaction transaction, IRoleType roleType)

Disallows the instances of this IThingType from playing the given role.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

roleType

The role to not be played by the instances of this type.

IRoleType

Returns

VoidPromise

Code examples
thingType.UnsetPlays(transaction, roleType).Resolve();

IEntityType

Package: TypeDB.Driver.Api

Supertypes:

  • TypeDB.Driver.Api.IThingType

  • TypeDB.Driver.Api.IType

  • TypeDB.Driver.Api.IConcept

Entity types represent the classification of independent objects in the data model of the business domain.

AsEntityType

IEntityType IConcept. AsEntityType()

Casts the concept to IEntityType.

Implements TypeDB.Driver.Api.IConcept.

Returns

IEntityType IConcept.

Code examples
concept.AsEntityType();

Create

Promise< IEntity > Create(ITypeDBTransaction transaction)

Creates and returns a new instance of this IEntityType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

Promise< IEntity >

Code examples
entityType.Create(transaction).Resolve();

IsEntityType

bool IConcept. IsEntityType()

Checks if the concept is an IEntityType.

Implements TypeDB.Driver.Api.IConcept.

Returns

bool IConcept.

Code examples
concept.IsEntityType();

SetSupertype

VoidPromise SetSupertype(ITypeDBTransaction transaction, IEntityType superEntityType)

Sets the supplied IEntityType as the supertype of the current IEntityType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

superEntityType

The IEntityType to set as the supertype of this IEntityType

IEntityType

Returns

VoidPromise

Code examples
entityType.SetSupertype(transaction, entityType).Resolve();

IRelationType

Package: TypeDB.Driver.Api

Supertypes:

  • TypeDB.Driver.Api.IThingType

  • TypeDB.Driver.Api.IType

  • TypeDB.Driver.Api.IConcept

Relation types (or subtypes of the relation root type) represent relationships between types. Relation types have roles. Other types can play roles in relations if it’s mentioned in their definition. A relation type must specify at least one role.

AsRelationType

IRelationType IConcept. AsRelationType()

Casts the concept to IRelationType.

Implements TypeDB.Driver.Api.IConcept.

Returns

IRelationType IConcept.

Code examples
concept.AsRelationType();

Create

Promise< IRelation > Create(ITypeDBTransaction transaction)

Creates and returns an instance of this IRelationType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

Promise< IRelation >

Code examples
relationType.Create(transaction).Resolve();

GetRelates

IEnumerable< IRoleType > GetRelates(ITypeDBTransaction transaction)

Retrieves roles that this IRelationType relates to directly or via inheritance.

See also

IRelationType::getRelates(ITypeDBTransaction, IConcept.Transitivity)
Returns

IEnumerable< IRoleType >

GetRelates

IEnumerable< IRoleType > GetRelates(ITypeDBTransaction transaction, IConcept.Transitivity transitivity)

Retrieves roles that this IRelationType relates to directly or via inheritance.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

transitivity

Transitive for direct and inherited relates, Explicit for direct relates only

IConcept​.Transitivity

Returns

IEnumerable< IRoleType >

Code examples
relationType.GetRelates(transaction, transitivity);

GetRelates

Promise< IRoleType > GetRelates(ITypeDBTransaction transaction, string roleLabel)

Retrieves roles that this IRelationType relates to directly or via inheritance. If role_label is given, returns a corresponding IRoleType or null.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

roleLabel

Label of the role we wish to retrieve

string

Returns

Promise< IRoleType >

Code examples
relationType.GetRelates(transaction, roleLabel).Resolve();

GetRelatesOverridden

Promise< IRoleType > GetRelatesOverridden(ITypeDBTransaction transaction, IRoleType roleType)

Retrieves a IRoleType that is overridden by the role with the role_label.

See also

IRelationType::GetRelatesOverridden(ITypeDBTransaction, string)
Returns

Promise< IRoleType >

GetRelatesOverridden

Promise< IRoleType > GetRelatesOverridden(ITypeDBTransaction transaction, string roleLabel)

Retrieves a IRoleType that is overridden by the role with the role_label.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

roleLabel

Label of the role that overrides an inherited role

string

Returns

Promise< IRoleType >

Code examples
relationType.GetRelatesOverridden(transaction, roleLabel).Resolve();

IsRelationType

bool IConcept. IsRelationType()

Checks if the concept is a IRelationType.

Implements TypeDB.Driver.Api.IConcept.

Returns

bool IConcept.

Code examples
concept.IsRelationType();

SetRelates

VoidPromise SetRelates(ITypeDBTransaction transaction, string roleLabel)

Sets the new role that this IRelationType relates to.

See also

IRelationType::SetRelates(ITypeDBTransaction, string, string)
Returns

VoidPromise

SetRelates

VoidPromise SetRelates(ITypeDBTransaction transaction, string roleLabel, IRoleType overriddenType)

Sets the new role that this IRelationType relates to.

See also

IRelationType::SetRelates(ITypeDBTransaction, string, string)
Returns

VoidPromise

SetRelates

VoidPromise SetRelates(ITypeDBTransaction transaction, string roleLabel, string? overriddenLabel)

Sets the new role that this IRelationType relates to. If we are setting an overriding type this way, we have to also pass the overridden type as a second argument.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

roleLabel

The new role for the IRelationType to relate to

string

overriddenLabel

The label being overridden, if applicable

string?

Returns

VoidPromise

Code examples
relationType.SetRelates(transaction, roleLabel).Resolve();
relationType.SetRelates(transaction, roleLabel, overriddenLabel).Resolve();

SetSupertype

VoidPromise SetSupertype(ITypeDBTransaction transaction, IRelationType superRelationType)

Sets the supplied IRelationType as the supertype of the current IRelationType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

superRelationType

The IRelationType to set as the supertype of this IRelationType

IRelationType

Returns

VoidPromise

Code examples
relationType.SetSupertype(transaction, superRelationType).Resolve();

UnsetRelates

VoidPromise UnsetRelates(ITypeDBTransaction transaction, IRoleType roleType)

Disallows this IRelationType from relating to the given role.

See also

IRelationType::UnsetRelates(ITypeDBTransaction, string)
Returns

VoidPromise

UnsetRelates

VoidPromise UnsetRelates(ITypeDBTransaction transaction, string roleLabel)

Disallows this IRelationType from relating to the given role.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

roleLabel

The role to not relate to the relation type.

string

Returns

VoidPromise

Code examples
relationType.UnsetRelates(transaction, roleLabel).Resolve();

IRoleType

Package: TypeDB.Driver.Api

Supertypes:

  • TypeDB.Driver.Api.IType

  • TypeDB.Driver.Api.IConcept

Roles are special internal types used by relations. We can not create an instance of a role in a database. But we can set an instance of another type (role player) to play a role in a particular instance of a relation type. Roles allow a schema to enforce logical constraints on types of role players.

AsRoleType

IRoleType IConcept. AsRoleType()

Casts the concept to IRoleType.

Implements TypeDB.Driver.Api.IConcept.

Returns

IRoleType IConcept.

Code examples
concept.AsRoleType();

GetPlayerInstances

IEnumerable< IThing > GetPlayerInstances(ITypeDBTransaction transaction)

Retrieves the Thing instances that play this role.

See also

IRoleType::GetPlayerInstances(ITypeDBTransaction, IConcept.Transitivity)
Returns

IEnumerable< IThing >

GetPlayerInstances

IEnumerable< IThing > GetPlayerInstances(ITypeDBTransaction transaction, IConcept.Transitivity transitivity)

Retrieves the Thing instances that play this role.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

transitivity

Transitive for direct and indirect playing, Explicit for direct playing only

IConcept​.Transitivity

Returns

IEnumerable< IThing >

Code examples
roleType.GetPlayerInstances(transaction, transitivity);

GetPlayerTypes

IEnumerable< IThingType > GetPlayerTypes(ITypeDBTransaction transaction)

Retrieves the ThingTypes whose instances play this role. Equivalent to GetPlayerTypes(transaction, Transitive).

See also

IRoleType::GetPlayerTypes(ITypeDBTransaction, IConcept.Transitivity)
Returns

IEnumerable< IThingType >

GetPlayerTypes

IEnumerable< IThingType > GetPlayerTypes(ITypeDBTransaction transaction, IConcept.Transitivity transitivity)

Retrieves the ThingTypes whose instances play this role.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

transitivity

Transitive for direct and indirect playing, Explicit for direct playing only

IConcept​.Transitivity

Returns

IEnumerable< IThingType >

Code examples
roleType.GetPlayerTypes(transaction, transitivity)

GetRelationInstances

IEnumerable< IRelation > GetRelationInstances(ITypeDBTransaction transaction)

Retrieves the Relation instances that this role is related to. Equivalent to GetRelationInstances(transaction, Transitive)

See also

IRoleType::GetRelationInstances(ITypeDBTransaction, IConcept.Transitivity)
Returns

IEnumerable< IRelation >

GetRelationInstances

IEnumerable< IRelation > GetRelationInstances(ITypeDBTransaction transaction, IConcept.Transitivity transitivity)

Retrieves the Relation instances that this role is related to.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

transitivity

Transitive for direct and indirect relation, Explicit for direct relation only

IConcept​.Transitivity

Returns

IEnumerable< IRelation >

Code examples
roleType.GetRelationInstances(transaction, transitivity)

GetRelationTypes

IEnumerable< IRelationType > GetRelationTypes(ITypeDBTransaction transaction)

Retrieves RelationTypes that this role is related to (directly or indirectly).

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

IEnumerable< IRelationType >

Code examples
roleType.GetRelationTypes(transaction);

IsRoleType

bool IConcept. IsRoleType()

Checks if the concept is a IRoleType.

Implements TypeDB.Driver.Api.IConcept.

Returns

bool IConcept.

Code examples
concept.IsRoleType();

IAttributeType

Package: TypeDB.Driver.Api

Supertypes:

  • TypeDB.Driver.Api.IThingType

  • TypeDB.Driver.Api.IType

  • TypeDB.Driver.Api.IConcept

Attribute types represent properties that other types can own.

IAttribute types have a value type. This value type is fixed and unique for every given instance of the attribute type.

Other types can own an attribute type. That means that instances of these other types can own an instance of this attribute type. This usually means that an object in our domain has a property with the matching value.

Multiple types can own the same attribute type, and different instances of the same type or different types can share ownership of the same attribute instance.

AsAttributeType

IAttributeType IConcept. AsAttributeType()

Casts the concept to IAttributeType.

Implements TypeDB.Driver.Api.IConcept.

Returns

IAttributeType IConcept.

Code examples
concept.AsAttributeType();

Get

Promise< IAttribute > Get(ITypeDBTransaction transaction, IValue value)

Retrieves an IAttribute of this IAttributeType with the given value if such IAttribute exists. Otherwise, returns None.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

value

IAttribute’s value

IValue

Returns

Promise< IAttribute >

Code examples
attributeType.Get(transaction, value).Resolve();

Get

Promise< IAttribute > Get(ITypeDBTransaction transaction, string value)

Retrieves an IAttribute of this IAttributeType with the given value if such IAttribute exists. Otherwise, returns None.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

value

IAttribute’s value

string

Returns

Promise< IAttribute >

Code examples
attributeType.Get(transaction, value).Resolve();

Get

Promise< IAttribute > Get(ITypeDBTransaction transaction, long value)

Retrieves an IAttribute of this IAttributeType with the given value if such IAttribute exists. Otherwise, returns None.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

value

IAttribute’s value

long

Returns

Promise< IAttribute >

Code examples
attributeType.Get(transaction, value).Resolve();

Get

Promise< IAttribute > Get(ITypeDBTransaction transaction, double value)

Retrieves an IAttribute of this IAttributeType with the given value if such IAttribute exists. Otherwise, returns None.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

value

IAttribute’s value

double

Returns

Promise< IAttribute >

Code examples
attributeType.Get(transaction, value).Resolve();

Get

Promise< IAttribute > Get(ITypeDBTransaction transaction, bool value)

Retrieves an IAttribute of this IAttributeType with the given value if such IAttribute exists. Otherwise, returns None.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

value

IAttribute’s value

bool

Returns

Promise< IAttribute >

Code examples
attributeType.Get(transaction, value).Resolve();

Get

Promise< IAttribute > Get(ITypeDBTransaction transaction, System.DateTime value)

Retrieves an IAttribute of this IAttributeType with the given value if such IAttribute exists. Otherwise, returns None.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

value

IAttribute’s value

System​.DateTime

Returns

Promise< IAttribute >

Code examples
attributeType.Get(transaction, value).Resolve();

GetOwners

IEnumerable< IThingType > GetOwners(ITypeDBTransaction transaction)

Retrieve all Things that own an attribute of this IAttributeType directly or through inheritance.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

IEnumerable< IThingType >

Code examples
attributeType.GetOwners(transaction);

GetOwners

IEnumerable< IThingType > GetOwners(ITypeDBTransaction transaction, ICollection< Annotation > annotations)

Retrieve all Things that own an attribute of this IAttributeType, filtered by Annotations, directly or through inheritance.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

annotations

Only retrieve ThingTypes that have an attribute of this IAttributeType with all given Annotations

ICollection< Annotation >

Returns

IEnumerable< IThingType >

Code examples
attributeType.GetOwners(transaction, annotations);

GetOwners

IEnumerable< IThingType > GetOwners(ITypeDBTransaction transaction, IConcept.Transitivity transitivity)

Retrieve all Things that own an attribute of this IAttributeType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

transitivity

Transitive for direct and inherited ownership, Explicit for direct ownership only

IConcept​.Transitivity

Returns

IEnumerable< IThingType >

Code examples
attributeType.GetOwners(transaction, transitivity);

GetOwners

IEnumerable< IThingType > GetOwners(ITypeDBTransaction transaction, ICollection< Annotation > annotations, IConcept.Transitivity transitivity)

Retrieve all Things that own an attribute of this IAttributeType, filtered by Annotations.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

annotations

Only retrieve ThingTypes that have an attribute of this IAttributeType with all given Annotations

ICollection< Annotation >

transitivity

Transitive for direct and inherited ownership, Explicit for direct ownership only

IConcept​.Transitivity

Returns

IEnumerable< IThingType >

Code examples
attributeType.GetOwners(transaction, annotations, transitivity);

GetRegex

Promise< string > GetRegex(ITypeDBTransaction transaction)

Retrieves the regular expression that is defined for this IAttributeType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

Promise< string >

Code examples
attributeType.GetRegex(transaction).Resolve();

GetSubtypes

IEnumerable< IType > GetSubtypes(ITypeDBTransaction transaction, IValue.ValueType valueType)

Retrieves all direct and indirect subtypes of this IAttributeType with given IValue.ValueType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

valueType

IValue.ValueType for retrieving subtypes

IValue​.ValueType

Returns

IEnumerable< IType >

Code examples
attributeType.GetSubtypes(transaction, valueType);

GetSubtypes

IEnumerable< IType > GetSubtypes(ITypeDBTransaction transaction, IValue.ValueType valueType, IConcept.Transitivity transitivity)

Retrieves all direct and indirect (or direct only) subtypes of this IAttributeType with given IValue.ValueType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

valueType

IValue.ValueType for retrieving subtypes

IValue​.ValueType

transitivity

Transitive for direct and indirect subtypes, Explicit for direct subtypes only

IConcept​.Transitivity

Returns

IEnumerable< IType >

Code examples
attributeType.GetSubtypes(transaction, valueType, transitivity);

IsAttributeType

bool IConcept. IsAttributeType()

Checks if the concept is an IAttributeType.

Implements TypeDB.Driver.Api.IConcept.

Returns

bool IConcept.

Code examples
concept.IsAttributeType();

IsBool

bool IsBool()

Returns True if the value for attributes of this type is of type bool. Otherwise, returns False.

Returns

bool

Code examples
attributeType.IsBool();

IsDateTime

bool IsDateTime()

Returns True if the value for attributes of this type is of type datetime. Otherwise, returns False.

Returns

bool

Code examples
attributeType.IsDateTime();

IsDouble

bool IsDouble()

Returns True if the value for attributes of this type is of type double. Otherwise, returns False.

Returns

bool

Code examples
attributeType.IsDouble();

IsLong

bool IsLong()

Returns True if the value for attributes of this type is of type long. Otherwise, returns False.

Returns

bool

Code examples
attributeType.IsLong();

IsString

bool IsString()

Returns True if the value for attributes of this type is of type string. Otherwise, returns False.

Returns

bool

Code examples
attributeType.IsString();

Put

Promise< IAttribute > Put(ITypeDBTransaction transaction, IValue value)

Adds and returns an IAttribute of this IAttributeType with the given value.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

value

New IAttribute’s value

IValue

Returns

Promise< IAttribute >

Code examples
attributeType.Put(transaction, value).Resolve();

Put

Promise< IAttribute > Put(ITypeDBTransaction transaction, string value)

Adds and returns an IAttribute of this IAttributeType with the given string value.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

value

New IAttribute’s value

string

Returns

Promise< IAttribute >

Code examples
attributeType.Put(transaction, value).Resolve();

Put

Promise< IAttribute > Put(ITypeDBTransaction transaction, long value)

Adds and returns an IAttribute of this IAttributeType with the given long value.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

value

New IAttribute’s value

long

Returns

Promise< IAttribute >

Code examples
attributeType.Put(transaction, value).Resolve();

Put

Promise< IAttribute > Put(ITypeDBTransaction transaction, double value)

Adds and returns an IAttribute of this IAttributeType with the given double value.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

value

New IAttribute’s value

double

Returns

Promise< IAttribute >

Code examples
attributeType.Put(transaction, value).Resolve();

Put

Promise< IAttribute > Put(ITypeDBTransaction transaction, bool value)

Adds and returns an IAttribute of this IAttributeType with the given bool value.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

value

New IAttribute’s value

bool

Returns

Promise< IAttribute >

Code examples
attributeType.Put(transaction, value).Resolve();

Put

Promise< IAttribute > Put(ITypeDBTransaction transaction, System.DateTime value)

Adds and returns an IAttribute of this IAttributeType with the given DateTime value. The input DateTime value is treated as timezone naive, with DateTimeKind being ignored.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

value

New IAttribute’s value

System​.DateTime

Returns

Promise< IAttribute >

Code examples
attributeType.Put(transaction, value).Resolve();

SetRegex

VoidPromise SetRegex(ITypeDBTransaction transaction, string regex)

Sets a regular expression as a constraint for this IAttributeType. Values of all IAttributes of this type (inserted earlier or later) should match this regex.

Can only be applied for IAttributeTypes with a string value type.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

regex

Regular expression

string

Returns

VoidPromise

Code examples
attributeType.SetRegex(transaction, regex).Resolve();

SetSupertype

VoidPromise SetSupertype(ITypeDBTransaction transaction, IAttributeType attributeType)

Sets the supplied IAttributeType as the supertype of the current IAttributeType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

attributeType

The IAttributeType to set as the supertype of this IAttributeType

IAttributeType

Returns

VoidPromise

Code examples
attributeType.SetSupertype(transaction, superType).Resolve();

UnsetRegex

VoidPromise UnsetRegex(ITypeDBTransaction transaction)

Removes the regular expression that is defined for this IAttributeType.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

VoidPromise

Code examples
attributeType.UnsetRegex(transaction).Resolve();

ValueType

IValue.ValueType TypeDB.Driver.Api.IAttributeType.ValueType

The IValue.ValueType of this IAttributeType.

Returns

IValue.ValueType

Code examples
attributeType.ValueType;

Annotation

Package: TypeDB.Driver.Api.IThingType

Annotation

Equals

override bool Equals(object? obj)

Checks if this Annotation is equal to another object.

Input parameters
Name Description Type

obj

Object to compare with

object?

Returns

override bool

Code examples
annotation.Equals(obj);

IsKey

bool IsKey()

Checks if this Annotation is a @key annotation.

Returns

bool

Code examples
annotation.IsKey();

IsUnique

bool IsUnique()

Checks if this Annotation is a @unique annotation.

Returns

bool

Code examples
annotation.IsUnique();

NewKey

static Annotation NewKey()

Produces a @key annotation.

Returns

Annotation

Code examples
using static TypeDB.Driver.Api.IThingType.Annotation;
NewKey();

NewUnique

static Annotation NewUnique()

Produces a @unique annotation.

Returns

Annotation

Code examples
Annotation.NewUnique();

ToString

override string ToString()

Retrieves a string representation of this Annotation.

Returns

override string

Code examples
annotation.ToString();

Label

Package: TypeDB.Driver.Common

A Label holds the uniquely identifying name of a type.

It consists of an optional scope, and a name, represented scope:name. The scope is used only used to distinguish between role-types of the same name declared in different relation types.

Fields
Name Type Description

readonly string TypeDB​.Driver​.Common​.Label​.Name

readonly string TypeDB​.Driver​.Common​.Label​.Name

Returns the name of this Label. Examples

label.Name;

readonly? string TypeDB​.Driver​.Common​.Label​.Scope

readonly? string TypeDB​.Driver​.Common​.Label​.Scope

Returns the scope of this Label. Examples

label.Scope;

Equals

override bool Equals(object? obj)

Checks if this Label is equal to another object.

Input parameters
Name Description Type

obj

Object to compare with

object?

Returns

override bool

Code examples
label.Equals(obj);

Label

Label(string? scope, string name)

Creates a Label from a specified scope and name.

Input parameters
Name Description Type

scope

Label scope

string?

name

Label name

string

Returns

Label

Code examples
new Label("relation", "role");

Label

Label(string name)

Creates a Label from a specified name.

Input parameters
Name Description Type

name

Label name

string

Returns

Label

Code examples
new Label("entity");

ScopedName

string TypeDB.Driver.Common.Label.ScopedName

Returns the string representation of the scoped name.

Returns

string

Code examples
label.ScopedName;

ToString

override string ToString()

Returns the string representation of the scoped name.

Returns

override string

Code examples
label.ToString();

Data

IThing

Package: TypeDB.Driver.Api

Supertypes:

  • TypeDB.Driver.Api.IConcept

AsThing

IThing IConcept. AsThing()

Casts the concept to IThing.

Implements TypeDB.Driver.Api.IConcept.

Returns

IThing IConcept.

Code examples
thing.AsThing();

Delete

VoidPromise Delete(ITypeDBTransaction transaction)

Deletes this IThing.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

VoidPromise

Code examples
thing.Delete(transaction).Resolve();

GetHas

IEnumerable< IAttribute > GetHas(ITypeDBTransaction transaction, params IAttributeType[] attributeTypes)

Retrieves the IAttributes that this IThing owns, optionally filtered by IAttributeTypes.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

attributeTypes

The IAttributeTypes to filter the attributes by

params IAttributeType[]

Returns

IEnumerable< IAttribute >

Code examples
thing.GetHas(transaction);
thing.GetHas(transaction, attributeType);

GetHas

IEnumerable< IAttribute > GetHas(ITypeDBTransaction transaction, ICollection< Annotation > annotations)

Retrieves the IAttributes that this IThing owns, filtered by Annotations.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

annotations

Only retrieve attributes with all given Annotations

ICollection< Annotation >

Returns

IEnumerable< IAttribute >

Code examples
thing.GetHas(transaction);
thing.GetHas(transaction, new []{NewKey()});

GetPlaying

IEnumerable< IRoleType > GetPlaying(ITypeDBTransaction transaction)

Retrieves the roles that this IThing is currently playing.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

IEnumerable< IRoleType >

Code examples
thing.GetPlaying(transaction);

GetRelations

IEnumerable< IRelation > GetRelations(ITypeDBTransaction transaction, params IRoleType[] roleTypes)

Retrieves all the Relations which this IThing plays a role in, optionally filtered by one or more given roles.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

roleTypes

The array of roles to filter the relations by.

params IRoleType[]

Returns

IEnumerable< IRelation >

Code examples
thing.GetRelations(transaction, roleTypes);

IID

string TypeDB.Driver.Api.IThing.IID

The unique id of the IThing.

Returns

string

Code examples
thing.IID;

IsDeleted

Promise< bool > IsDeleted(ITypeDBTransaction transaction)

Checks if this IThing is deleted.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

Promise< bool >

Code examples
thing.IsDeleted(transaction).Resolve();

IsInferred

bool IsInferred()

Checks if this IThing is inferred by a [Reasoning Rule].

Returns

bool

Code examples
thing.IsInferred();

IsThing

bool IConcept. IsThing()

Checks if the concept is a IThing.

Implements TypeDB.Driver.Api.IConcept.

Returns

bool IConcept.

Code examples
thing.IsThing();

SetHas

VoidPromise SetHas(ITypeDBTransaction transaction, IAttribute attribute)

Assigns an IAttribute to be owned by this IThing.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

attribute

The IAttribute to be owned by this IThing.

IAttribute

Returns

VoidPromise

Code examples
thing.SetHas(transaction, attribute).Resolve();

Type

IThingType TypeDB.Driver.Api.IThing.Type

The type which this IThing belongs to.

Returns

IThingType

Code examples
thing.Type;

UnsetHas

VoidPromise UnsetHas(ITypeDBTransaction transaction, IAttribute attribute)

Unassigns an IAttribute from this IThing.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

attribute

The IAttribute to be disowned from this IThing.

IAttribute

Returns

VoidPromise

Code examples
thing.UnsetHas(transaction, attribute).Resolve();

IEntity

Package: TypeDB.Driver.Api

Supertypes:

  • TypeDB.Driver.Api.IThing

  • TypeDB.Driver.Api.IConcept

Instance of data of an entity type, representing a standalone object that exists in the data model independently. Entity does not have a value. It is usually addressed by its ownership over attribute instances and/or roles played in relation instances.

AsEntity

IEntity IConcept. AsEntity()

Casts the concept to IEntity.

Implements TypeDB.Driver.Api.IConcept.

Returns

IEntity IConcept.

Code examples
entity.AsEntity();

IsEntity

bool IConcept. IsEntity()

Checks if the concept is an IEntity.

Implements TypeDB.Driver.Api.IConcept.

Returns

bool IConcept.

Code examples
entity.IsEntity();

IRelation

Package: TypeDB.Driver.Api

Supertypes:

  • TypeDB.Driver.Api.IThing

  • TypeDB.Driver.Api.IConcept

Relation is an instance of a relation type and can be uniquely addressed by a combination of its type, owned attributes and role players.

AddPlayer

VoidPromise AddPlayer(ITypeDBTransaction transaction, IRoleType roleType, IThing player)

Adds a new role player to play the given role in this IRelation.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

roleType

The role to be played by the player

IRoleType

player

The thing to play the role

IThing

Returns

VoidPromise

Code examples
relation.AddPlayer(transaction, roleType, player).Resolve();

AsRelation

IRelation IConcept. AsRelation()

Casts the concept to IRelation.

Implements TypeDB.Driver.Api.IConcept.

Returns

IRelation IConcept.

Code examples
relation.AsRelation();

GetPlayers

Dictionary< IRoleType, ICollection< IThing > > GetPlayers(ITypeDBTransaction transaction)

Retrieves a mapping of all instances involved in the IRelation and the role each play.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

Dictionary< IRoleType, ICollection< IThing > >

Code examples
relation.GetPlayers(transaction)

GetPlayersByRoleType

IEnumerable< IThing > GetPlayersByRoleType(ITypeDBTransaction transaction, params IRoleType[] roleTypes)

Retrieves all role players of this IRelation, optionally filtered by given role types.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

roleTypes

0 or more role types

params IRoleType[]

Returns

IEnumerable< IThing >

Code examples
relation.GetPlayersByRoleType(transaction, roleTypes);

GetRelating

IEnumerable< IRoleType > GetRelating(ITypeDBTransaction transaction)

Retrieves all role types currently played in this IRelation.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

IEnumerable< IRoleType >

Code examples
relation.GetRelating(transaction);

IsRelation

bool IConcept. IsRelation()

Checks if the concept is a IRelation.

Implements TypeDB.Driver.Api.IConcept.

Returns

bool IConcept.

Code examples
relation.IsRelation();

RemovePlayer

VoidPromise RemovePlayer(ITypeDBTransaction transaction, IRoleType roleType, IThing player)

Removes the association of the given instance that plays the given role in this IRelation.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

roleType

The role to no longer be played by the thing in this IRelation

IRoleType

player

The instance to no longer play the role in this IRelation

IThing

Returns

VoidPromise

Code examples
relation.RemovePlayer(transaction, roleType, player).Resolve();

IAttribute

Package: TypeDB.Driver.Api

Supertypes:

  • TypeDB.Driver.Api.IThing

  • TypeDB.Driver.Api.IConcept

Attribute is an instance of the attribute type and has a value. This value is fixed and unique for every given instance of the attribute type.

Attributes can be uniquely addressed by their type and value.

AsAttribute

IAttribute IConcept. AsAttribute()

Casts the concept to IAttribute.

Implements TypeDB.Driver.Api.IConcept.

Returns

IAttribute IConcept.

Code examples
attribute.AsAttribute();

GetOwners

IEnumerable< IThing > GetOwners(ITypeDBTransaction transaction)

Retrieves the instances that own this IAttribute.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

Returns

IEnumerable< IThing >

Code examples
attribute.GetOwners(transaction);

GetOwners

IEnumerable< IThing > GetOwners(ITypeDBTransaction transaction, IThingType ownerType)

Retrieves the instances that own this IAttribute.

Input parameters
Name Description Type

transaction

The current transaction

ITypeDBTransaction

ownerType

Filter results for only owners of the given type

IThingType

Returns

IEnumerable< IThing >

Code examples
attribute.GetOwners(transaction, ownerType);

IsAttribute

bool IConcept. IsAttribute()

Checks if the concept is an IAttribute.

Implements TypeDB.Driver.Api.IConcept.

Returns

bool IConcept.

Code examples
attribute.IsAttribute();

Value

IValue TypeDB.Driver.Api.IAttribute.Value

Retrieves the value which the IAttribute instance holds.

Returns

IValue

Code examples
attribute.Value;

IValue

Package: TypeDB.Driver.Api

Supertypes:

  • TypeDB.Driver.Api.IConcept

AsBool

bool AsBool()

Returns a bool value of this value concept. If the value has another type, raises an exception.

Returns

bool

Code examples
value.AsBool();

AsDateTime

System.DateTime AsDateTime()

Returns a datetime value of this value concept. This value contains raw date and time without considering your time zone (Kind = Unspecified). If the value has another type, raises an exception.

Returns

System.DateTime

Code examples
value.AsDateTime();

AsDouble

double AsDouble()

Returns a double value of this value concept. If the value has another type, raises an exception.

Returns

double

Code examples
value.AsDouble();

AsLong

long AsLong()

Returns a long value of this value concept. If the value has another type, raises an exception.

Returns

long

Code examples
value.AsLong();

AsString

string AsString()

Returns a string value of this value concept. If the value has another type, raises an exception.

Returns

string

Code examples
value.AsString();

AsUntyped

object AsUntyped()

Returns an untyped object value of this value concept. This is useful for value equality or printing without having to switch on the actual contained value.

Returns

object

Code examples
value.AsUntyped();

AsValue

IValue IConcept. AsValue()

Casts the concept to IValue.

Implements TypeDB.Driver.Api.IConcept.

Returns

IValue IConcept.

Code examples
concept.AsValue();

IsBool

bool IsBool()

Returns True if the value which this value concept holds is of type bool. Otherwise, returns false.

Returns

bool

Code examples
value.IsBool();

IsDateTime

bool IsDateTime()

Returns True if the value which this value concept holds is of type datetime. Otherwise, returns false.

Returns

bool

Code examples
value.IsDateTime();

IsDouble

bool IsDouble()

Returns True if the value which this value concept holds is of type double. Otherwise, returns false.

Returns

bool

Code examples
value.IsDouble();

IsLong

bool IsLong()

Returns True if the value which this value concept holds is of type long. Otherwise, returns false.

Returns

bool

Code examples
value.IsLong();

IsString

bool IsString()

Returns True if the value which this value concept holds is of type string. Otherwise, returns false.

Returns

bool

Code examples
value.IsString();

IsValue

bool IConcept. IsValue()

Checks if the concept is a IValue.

Implements TypeDB.Driver.Api.IConcept.

Returns

bool IConcept.

Code examples
concept.IsValue();

Type

ValueType TypeDB.Driver.Api.IValue.Type

Retrieves the IValue.ValueType of this value concept.

Returns

ValueType

Code examples
value.Type;

ValueType

Package: TypeDB.Driver.Api.IValue

Used to specify the type of the value.

Examples
thingType.GetOwns(transaction, IValue.ValueType.String);
Enum constants
Name

Bool

DateTime

Double

Long

Object

String

ValueTypeExtensions

Package: TypeDB.Driver.Api

Extension class with additional methods describing characteristics of ValueType enum values.

GetValueClass

static System.Type GetValueClass(this IValue::ValueType valueType)

Returns a System.Type equivalent of this value concept for this programming language.

Returns

System.Type

Code examples
valueType.GetValueClass();

IsKeyable

static bool IsKeyable(this ValueType valueType)

Returns true if this value concept can be used as a key via the @key annotation. Otherwise, returns false.

Returns

bool

Code examples
valueType.IsKeyable();

IsWritable

static bool IsWritable(this IValue::ValueType valueType)

Returns true if this value concept can be written to a database. Otherwise, returns false.

Returns

bool

Code examples
valueType.IsWritable();

Logic

ILogicManager

Package: TypeDB.Driver.Api

Provides methods for manipulating rules in the database.

GetRule

Promise< IRule > GetRule(string label)

Retrieves the Rule that has the given label.

Input parameters
Name Description Type

label

The label of the Rule to create or retrieve

string

Returns

Promise< IRule >

Code examples
transaction.Logic.GetRule(label).Resolve()

GetRules

IEnumerable< IRule > GetRules()

Retrieves all rules.

Returns

IEnumerable< IRule >

Code examples
transaction.Logic.GetRules();

PutRule

Promise< IRule > PutRule(string label, string when, string then)

Creates a new Rule if none exists with the given label, or replaces the existing one.

Input parameters
Name Description Type

label

The label of the IRule to create or replace

string

when

The when body of the rule to create

string

then

The then body of the rule to create

string

Returns

Promise< IRule >

Code examples
transaction.Logic.PutRule(label, when, then).Resolve()

IRule

Package: TypeDB.Driver.Api

Rules are a part of schema and define embedded logic. The reasoning engine uses rules as a set of logic to infer new data. A rule consists of a condition and a conclusion, and is uniquely identified by a label.

Delete

VoidPromise Delete(ITypeDBTransaction transaction)

Deletes this rule.

Input parameters
Name Description Type

transaction

The current Transaction

ITypeDBTransaction

Returns

VoidPromise

Code examples
rule.Delete(transaction).Resolve();

IsDeleted

Promise< bool > IsDeleted(ITypeDBTransaction transaction)

Check if this rule has been deleted.

Input parameters
Name Description Type

transaction

The current Transaction

ITypeDBTransaction

Returns

Promise< bool >

Code examples
rule.IsDeleted(transaction).Resolve();

Label

string TypeDB.Driver.Api.IRule.Label

Retrieves the unique label of the rule.

Returns

string

SetLabel

VoidPromise SetLabel(ITypeDBTransaction transaction, string label)

Renames the label of the rule. The new label must remain unique.

Input parameters
Name Description Type

transaction

The current Transaction

ITypeDBTransaction

label

The new label to be given to the rule

string

Returns

VoidPromise

Code examples
rule.SetLabel(transaction, newLabel).Resolve();

Then

string TypeDB.Driver.Api.IRule.Then

The single statement that constitutes the ‘then’ of the rule.

Returns

string

When

string TypeDB.Driver.Api.IRule.When

The statements that constitute the ‘when’ of the rule.

Returns

string

Errors

TypeDBDriverException

Package: TypeDB.Driver.Common

Exceptions raised by the driver.

Contains

bool Contains(string subString)

Checks whether a substring is a part of this exception’s message.

Returns

bool

Code examples
try
{
    ...
}
catch (TypeDBDriverException e)
{
    if (e.Contains("CSCO01"))
    {
        ...
    }
    else
    {
        ...
    }
}