Python driver API reference
Connection
TypeDB
cloud_driver
static cloud_driver(addresses: Mapping[str, str] | Iterable[str] | str, credential: TypeDBCredential) -> TypeDBDriver
Creates a connection to TypeDB Cloud, authenticating with the provided credentials.
Name | Description | Type | Default Value |
---|---|---|---|
|
– |
|
|
|
– |
|
TypeDBDriver
TypeDBDriver
Name | Type | Description |
---|---|---|
|
|
The |
|
|
The |
close
close() -> None
Closes the driver. Before instantiating a new driver, the driver that’s currently open should first be closed.
None
driver.close()
is_open
is_open() -> bool
Checks whether this connection is presently open.
bool
driver.is_open()
session
session(database_name: str, session_type: SessionType, options: TypeDBOptions | None = None) -> TypeDBSession
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 TypeDBSession
section.
Name | Description | Type | Default Value |
---|---|---|---|
|
The name of the database with which the session connects |
|
|
|
The type of session to be created (DATA or SCHEMA) |
|
|
|
|
|
|
TypeDBSession
driver.session(database, session_type, options)
TypeDBCredential
User credentials and TLS encryption settings for connecting to TypeDB Cloud. Arguments: 1) username: The name of the user to connect as. 2) password: The password for the user. 3) tls_root_ca_path: Path to the CA certificate to use for authenticating server certificates. 4) tls_enabled: Specify whether the connection to TypeDB Cloud must be done over TLS.
# Creates a credential using the specified username and password.
credential = TypeDBCredential(username, password)
# Creates a credential as above, but with TLS and the specified CA to authenticate server certificates.
credential = TypeDBCredential(username, password, tls_enabled=True, tls_root_ca_path="path/to/ca-certificate.pem")
DatabaseManager
Provides access to all database management methods.
all
all() -> List[Database]
Retrieves all databases present on the TypeDB server
List[Database]
driver.databases.all()
contains
contains(name: str) -> bool
Checks if a database with the given name exists
Name | Description | Type | Default Value |
---|---|---|---|
|
The database name to be checked |
|
bool
driver.databases.contains(name)
Database
Name | Type | Description |
---|---|---|
|
|
The database name as a string. |
preferred_replica
preferred_replica() -> Replica | None
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
Replica | None
database.preferred_replica()
primary_replica
primary_replica() -> Replica | None
Returns the primary replica for this database. Only works in TypeDB Cloud
Replica | None
database.primary_replica()
replicas
replicas() -> Set[Replica]
Set of Replica
instances for this database. Only works in TypeDB Cloud
Set[Replica]
database.replicas()
rule_schema
rule_schema() -> str
Returns the rules in the schema as a valid TypeQL define query string.
str
database.rule_schema()
Replica
The metadata and state of an individual raft replica of a database.
is_preferred
is_preferred() -> bool
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.
bool
UserManager
Provides access to all user management methods.
all
all() -> List[User]
Retrieves all users which exist on the TypeDB server.
List[User]
driver.users.all()
contains
contains(username: str) -> bool
Checks if a user with the given name exists.
Name | Description | Type | Default Value |
---|---|---|---|
|
The user name to be checked |
|
bool
driver.users.contains(username)
create
create(username: str, password: str) -> None
Create a user with the given name and password.
Name | Description | Type | Default Value |
---|---|---|---|
|
The name of the user to be created |
|
|
|
The password of the user to be created |
|
None
driver.users.create(username, password)
delete
delete(username: str) -> None
Deletes a user with the given name.
Name | Description | Type | Default Value |
---|---|---|---|
|
The name of the user to be deleted |
|
None
driver.users.delete(username)
get
get(username: str) -> User | None
Retrieve a user with the given name.
Name | Description | Type | Default Value |
---|---|---|---|
|
The name of the user to retrieve |
|
User | None
driver.users.get(username)
password_set
password_set(username: str, password: str) -> None
Sets a new password for a user. This operation can only be performed by administrators.
Name | Description | Type | Default Value |
---|---|---|---|
|
The name of the user to set the password of |
|
|
|
The new password |
|
None
driver.users.password_set(username, password)
User
TypeDB user information
password_expiry_seconds
password_expiry_seconds() -> int | None
Returns the number of seconds remaining till this user’s current password expires.
int | None
Session
TypeDBSession
Name | Type | Description |
---|---|---|
|
|
Gets the options for the session |
|
|
The current session’s type (SCHEMA or DATA) |
close
close() -> None
Closes the session. Before opening a new session, the session currently open should first be closed.
None
session.close()
database_name
database_name() -> str
Returns the name of the database of the session.
str
session.database_name()
is_open
is_open() -> bool
Checks whether this session is open.
bool
session.is_open()
on_close
on_close(function: callable) -> None
Registers a callback function which will be executed when this session is closed.
Name | Description | Type | Default Value |
---|---|---|---|
|
The callback function. |
|
None
session.on_close(function)
on_reopen
on_reopen(function: callable) -> None
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.
Name | Description | Type | Default Value |
---|---|---|---|
|
The callback function. |
|
None
session.on_close(function)
transaction
transaction(transaction_type: TransactionType, options: TypeDBOptions = None) -> TypeDBTransaction
Opens a transaction to perform read or write queries on the database connected to the session.
Name | Description | Type | Default Value |
---|---|---|---|
|
The type of transaction to be created (READ or WRITE) |
|
|
|
Options for the session |
|
|
TypeDBTransaction
session.transaction(transaction_type, options)
SessionType
This class is used to specify the type of the session.
driver.session(database, SessionType.SCHEMA)
Name | Value |
---|---|
|
|
|
|
TypeDBOptions
TypeDB session and transaction options. TypeDBOptions
object can be used to override the default server behaviour.
Options could be specified either as constructor arguments or using properties assignment.
transaction_options = TypeDBOptions(infer=True, session_idle_timeout_millis=20000)
transaction_options.explain = True
Name | Type | Description |
---|---|---|
|
|
If set to |
|
|
If set to |
|
|
If set to |
|
|
If set to |
|
|
If set, specifies a guideline number of answers that the server should send before the driver issues a fresh request. |
|
|
If set to |
|
|
If set, specifies how long the driver should wait if opening a session or transaction is blocked by a schema write lock. |
|
|
If set, specifies a timeout that allows the server to close sessions if the driver terminates or becomes unresponsive. |
|
|
If set to |
|
|
If set, specifies a timeout for killing transactions automatically, preventing memory leaks in unclosed transactions. |
Transaction
TypeDBTransaction
Name | Type | Description |
---|---|---|
|
|
The |
|
|
The |
|
|
The options for the transaction |
|
|
The |
|
|
The transaction’s type (READ or WRITE) |
commit
commit() -> None
Commits the changes made via this transaction to the TypeDB database. Whether or not the transaction is commited successfully, it gets closed after the commit call.
None
transaction.commit()
is_open
is_open() -> bool
Checks whether this transaction is open.
bool
transaction.is_open()
TransactionType
This class is used to specify the type of transaction.
session.transaction(TransactionType.READ)
Name | Value |
---|---|
|
|
|
|
QueryManager
Provides methods for executing TypeQL queries in the transaction.
define
define(query: str, options: TypeDBOptions = None) -> Promise[None]
Performs a TypeQL Define query in the transaction.
Name | Description | Type | Default Value |
---|---|---|---|
|
The TypeQL Define query to be executed |
|
|
|
Specify query options |
|
|
Promise[None]
transaction.query.define(query, options).resolve()
delete
delete(query: str, options: TypeDBOptions | None = None) -> Promise[None]
Performs a TypeQL Delete query in the transaction.
Name | Description | Type | Default Value |
---|---|---|---|
|
The TypeQL Delete query to be executed |
|
|
|
Specify query options |
|
|
Promise[None]
transaction.query.delete(query, options).resolve()
explain
explain(explainable: ConceptMap.Explainable, options: TypeDBOptions | None = None) -> Iterator[Explanation]
Performs a TypeQL Explain query in the transaction.
Name | Description | Type | Default Value |
---|---|---|---|
|
The Explainable to be explained |
|
|
|
Specify query options |
|
|
Iterator[Explanation]
transaction.query.explain(explainable, options)
fetch
fetch(query: str, options: TypeDBOptions | None = None) -> Iterator[dict]
Performs a TypeQL Fetch query in the transaction.
Name | Description | Type | Default Value |
---|---|---|---|
|
The TypeQL Fetch query to be executed |
|
|
|
Specify query options |
|
|
Iterator[dict]
transaction.query.fetch(query, options)
get
get(query: str, options: TypeDBOptions | None = None) -> Iterator[ConceptMap]
Performs a TypeQL Match (Get) query in the transaction.
Name | Description | Type | Default Value |
---|---|---|---|
|
The TypeQL Match (Get) query to be executed |
|
|
|
Specify query options |
|
|
Iterator[ConceptMap]
transaction.query.get(query, options)
get_aggregate
get_aggregate(query: str, options: TypeDBOptions | None = None) -> Promise[Value | None]
Performs a TypeQL Match Aggregate query in the transaction.
Name | Description | Type | Default Value |
---|---|---|---|
|
The TypeQL Match Aggregate query to be executed |
|
|
|
Specify query options |
|
|
Promise[Value | None]
transaction.query.get_aggregate(query, options).resolve()
get_group
get_group(query: str, options: TypeDBOptions | None = None) -> Iterator[ConceptMapGroup]
Performs a TypeQL Match Group query in the transaction.
Name | Description | Type | Default Value |
---|---|---|---|
|
The TypeQL Match Group query to be executed |
|
|
|
Specify query options |
|
|
Iterator[ConceptMapGroup]
transaction.query.get_group(query, options)
get_group_aggregate
get_group_aggregate(query: str, options: TypeDBOptions | None = None) -> Iterator[ValueGroup]
Performs a TypeQL Match Group Aggregate query in the transaction.
Name | Description | Type | Default Value |
---|---|---|---|
|
The TypeQL Match Group Aggregate query to be executed |
|
|
|
Specify query options |
|
|
Iterator[ValueGroup]
transaction.query.get_group_aggregate(query, options)
insert
insert(query: str, options: TypeDBOptions | None = None) -> Iterator[ConceptMap]
Performs a TypeQL Insert query in the transaction.
Name | Description | Type | Default Value |
---|---|---|---|
|
The TypeQL Insert query to be executed |
|
|
|
Specify query options |
|
|
Iterator[ConceptMap]
transaction.query.insert(query, options)
undefine
undefine(query: str, options: TypeDBOptions = None) -> Promise[None]
Performs a TypeQL Undefine query in the transaction.
Name | Description | Type | Default Value |
---|---|---|---|
|
The TypeQL Undefine query to be executed |
|
|
|
Specify query options |
|
|
Promise[None]
transaction.query.undefine(query, options).resolve()
update
update(query: str, options: TypeDBOptions | None = None) -> Iterator[ConceptMap]
Performs a TypeQL Update query in the transaction.
Name | Description | Type | Default Value |
---|---|---|---|
|
The TypeQL Update query to be executed |
|
|
|
Specify query options |
|
|
Iterator[ConceptMap]
transaction.query.update(query, options)
Answer
ConceptMapGroup
Contains an element of the group query result.
ConceptMap
Contains a mapping of variables to concepts.
concepts
concepts() -> Iterator[Concept]
Produces an iterator over all concepts in this ConceptMap
.
Iterator[Concept]
concept_map.concepts()
explainables
explainables() -> Explainables
Gets the Explainables
object for this ConceptMap
, exposing which of the concepts in this ConceptMap
are explainable.
Explainables
concept_map.explainables()
get
get(variable: str) -> Concept
Retrieves a concept for a given variable name.
Name | Description | Type | Default Value |
---|---|---|---|
|
The string representation of a variable |
|
Concept
concept_map.get(variable)
ValueGroup
Contains an element of the group aggregate query result.
Promise
A Promise
represents an asynchronous network operation.
The request it represents is performed immediately. The response is only retrieved once the Promise
is resolve
d.
Explainables
Contains explainable objects.
attribute
attribute(variable: str) -> Explainable
Retrieves the explainable attribute with the given variable name.
Name | Description | Type | Default Value |
---|---|---|---|
|
The string representation of a variable |
|
Explainable
concept_map.explainables().attribute(variable)
attributes
attributes() -> Mapping[str, Explainable]
Retrieves all of this ConceptMap
’s explainable attributes.
Mapping[str, Explainable]
concept_map.explainables().attributes()
ownership
ownership(owner: str, attribute: str) -> Explainable
Retrieves the explainable attribute ownership with the pair of (owner, attribute) variable names.
Name | Description | Type | Default Value |
---|---|---|---|
|
The string representation of the owner variable |
|
|
|
The string representation of the attribute variable |
|
Explainable
concept_map.explainables().ownership(owner, attribute)
ownerships
ownerships() -> Mapping[tuple[str, str], Explainable]
Retrieves all of this ConceptMap
’s explainable ownerships.
Mapping[tuple[str, str], Explainable]
concept_map.explainables().ownerships()
Explainable
Contains an explainable object.
Explanation
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
conclusion() -> ConceptMap
Retrieves the Conclusion for this Explanation.
ConceptMap
explanation.conclusion()
condition
condition() -> ConceptMap
Retrieves the Condition for this Explanation.
ConceptMap
explanation.condition()
query_variable_mapping
query_variable_mapping(var: str) -> set[str]
Retrieves the rule variables corresponding to the query variable var for this Explanation
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The query variable to map to rule variables. |
|
set[str]
explanation.variable_mapping(var)
Concept
ConceptManager
Provides access for all Concept API methods.
get_attribute
get_attribute(iid: str) -> Promise[Attribute]
Retrieves an Attribute
by its iid.
Name | Description | Type | Default Value |
---|---|---|---|
|
The iid of the |
|
Promise[Attribute]
transaction.concepts.get_attribute(iid).resolve()
get_attribute_type
get_attribute_type(label: str) -> Promise[AttributeType]
Retrieves an AttributeType
by its label.
Name | Description | Type | Default Value |
---|---|---|---|
|
The label of the |
|
Promise[AttributeType]
transaction.concepts.get_attribute_type(label).resolve()
get_entity
get_entity(iid: str) -> Promise[Entity]
Retrieves an Entity
by its iid.
Name | Description | Type | Default Value |
---|---|---|---|
|
The iid of the |
|
Promise[Entity]
transaction.concepts.get_entity(iid).resolve()
get_entity_type
get_entity_type(label: str) -> Promise[EntityType]
Retrieves an EntityType
by its label.
Name | Description | Type | Default Value |
---|---|---|---|
|
The label of the |
|
Promise[EntityType]
transaction.concepts.get_entity_type(label).resolve()
get_relation
get_relation(iid: str) -> Promise[Relation]
Retrieves a Relation
by its iid.
Name | Description | Type | Default Value |
---|---|---|---|
|
The iid of the |
|
Promise[Relation]
transaction.concepts.get_relation(iid).resolve()
get_relation_type
get_relation_type(label: str) -> Promise[RelationType]
Retrieves a RelationType
by its label.
Name | Description | Type | Default Value |
---|---|---|---|
|
The label of the |
|
Promise[RelationType]
transaction.concepts.get_relation_type(label).resolve()
get_root_attribute_type
get_root_attribute_type() -> AttributeType
Retrieve the root AttributeType
, “attribute”.
AttributeType
transaction.concepts.get_root_attribute_type()
get_root_entity_type
get_root_entity_type() -> EntityType
Retrieves the root EntityType
, “entity”.
EntityType
transaction.concepts.get_root_entity_type()
get_root_relation_type
get_root_relation_type() -> RelationType
Retrieve the root RelationType
, “relation”.
RelationType
transaction.concepts.get_root_relation_type()
get_schema_exception
get_schema_exception() -> list[TypeDBException]
Retrieves a list of all schema exceptions for the current transaction.
list[TypeDBException]
transaction.concepts.get_schema_exception()
put_attribute_type
put_attribute_type(label: str, value_type: ValueType) -> Promise[AttributeType]
Creates a new AttributeType
if none exists with the given label, or retrieves the existing one.
Name | Description | Type | Default Value |
---|---|---|---|
|
The label of the |
|
|
|
The value type of the |
|
Promise[AttributeType]
transaction.concepts.put_attribute_type(label, value_type).resolve()
put_entity_type
put_entity_type(label: str) -> Promise[EntityType]
Creates a new EntityType
if none exists with the given label, otherwise retrieves the existing one.
Name | Description | Type | Default Value |
---|---|---|---|
|
The label of the |
|
Promise[EntityType]
transaction.concepts.put_entity_type(label).resolve()
put_relation_type
put_relation_type(label: str) -> Promise[RelationType]
Creates a new RelationType
if none exists with the given label, otherwise retrieves the existing one.
Name | Description | Type | Default Value |
---|---|---|---|
|
The label of the |
|
Promise[RelationType]
transaction.concepts.put_relation_type(label).resolve()
Concept
as_attribute
as_attribute() -> Attribute
Casts the concept to Attribute
.
Attribute
concept.as_attribute()
as_attribute_type
as_attribute_type() -> AttributeType
Casts the concept to AttributeType
.
AttributeType
concept.as_attribute_type()
as_entity
as_entity() -> Entity
Casts the concept to Entity
.
Entity
concept.as_entity()
as_entity_type
as_entity_type() -> EntityType
Casts the concept to EntityType
.
EntityType
concept.as_entity_type()
as_relation
as_relation() -> Relation
Casts the concept to Relation
.
Relation
concept.as_relation()
as_relation_type
as_relation_type() -> RelationType
Casts the concept to RelationType
.
RelationType
concept.as_relation_type()
as_role_type
as_role_type() -> RoleType
Casts the concept to RoleType
.
RoleType
concept.as_role_type()
as_thing
as_thing() -> Thing
Casts the concept to Thing
.
Thing
concept.as_thing()
as_thing_type
as_thing_type() -> ThingType
Casts the concept to ThingType
.
ThingType
concept.as_thing_type()
as_value
as_value() -> Value
Casts the concept to Value
.
Value
concept.as_value()
is_attribute
is_attribute() -> bool
Checks if the concept is an Attribute
.
bool
concept.is_attribute()
is_attribute_type
is_attribute_type() -> bool
Checks if the concept is an AttributeType
.
bool
concept.is_attribute_type()
is_entity
is_entity() -> bool
Checks if the concept is an Entity
.
bool
concept.is_entity()
is_entity_type
is_entity_type() -> bool
Checks if the concept is an EntityType
.
bool
concept.is_entity_type()
is_relation
is_relation() -> bool
Checks if the concept is a Relation
.
bool
concept.is_relation()
is_relation_type
is_relation_type() -> bool
Checks if the concept is a RelationType
.
bool
concept.is_relation_type()
is_role_type
is_role_type() -> bool
Checks if the concept is a RoleType
.
bool
concept.is_role_type()
is_thing
is_thing() -> bool
Checks if the concept is a Thing
.
bool
concept.is_thing()
is_thing_type
is_thing_type() -> bool
Checks if the concept is a ThingType
.
bool
concept.is_thing_type()
Schema
Type
Supertypes:
-
Concept
delete
delete(transaction: TypeDBTransaction) -> Promise[None]
Deletes this type from the database.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[None]
type_.delete(transaction).resolve()
get_label
get_label() -> Label
Retrieves the unique label of the type.
Label
type_.get_label()
get_subtypes
get_subtypes(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[Type]
Retrieves all direct and indirect (or direct only) subtypes of the type.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[Type]
type_.get_subtypes(transaction)
type_.get_subtypes(transaction, Transitivity.EXPLICIT)
get_supertype
get_supertype(transaction: TypeDBTransaction) -> Promise[Type | None]
Retrieves the most immediate supertype of the type.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[Type | None]
type_.get_supertype(transaction).resolve()
get_supertypes
get_supertypes(transaction: TypeDBTransaction) -> Iterator[Type]
Retrieves all supertypes of the type.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Iterator[Type]
type_.get_supertypes(transaction)
is_abstract
is_abstract() -> bool
Checks if the type is prevented from having data instances (i.e., abstract
).
bool
type_.is_abstract()
is_root
is_root() -> bool
Checks if the type is a root type.
bool
type_.is_root()
is_type
is_type() -> bool
Checks if the concept is a Type
.
bool
type_.is_type()
set_label
set_label(transaction: TypeDBTransaction, new_label: str) -> Promise[None]
Renames the label of the type. The new label must remain unique.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The new name to be given to the type. |
|
Promise[None]
type_.set_label(transaction, new_label).resolve()
Label
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.
Name | Type | Description |
---|---|---|
|
|
The name part of the label |
|
|
The scope part of the label |
of
static of(*args: str) -> Label
Creates a Label from a specified name, or scoped name.
Name | Description | Type | Default Value |
---|---|---|---|
|
If a single string is provided, this is interpreted as the label name. If a pair of strings is provided, the first string is the scope and the second string is the name. |
|
Label
Label.of("entity")
Label.of("relation", "role")
ThingType
Supertypes:
-
Type
get_instances
get_instances(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[Thing]
Retrieves all direct and indirect (or direct only) Thing
objects that are instances of this ThingType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[Thing]
thing_type.get_instances(transaction)
thing_type.get_instances(transaction, Transitivity.EXPLICIT)
get_owns
get_owns(transaction: TypeDBTransaction, value_type: ValueType | None = None, transitivity: Transitivity = Transitivity.TRANSITIVE, annotations: set[Annotation] | None = None) -> Iterator[AttributeType]
Retrieves AttributeType
that the instances of this ThingType
are allowed to own directly or via inheritance.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
If specified, only attribute types of this |
|
|
|
|
|
|
|
Only retrieve attribute types owned with annotations. |
|
|
Iterator[AttributeType]
thing_type.get_owns(transaction)
thing_type.get_owns(transaction, value_type,
transitivity=Transitivity.EXPLICIT,
annotations={Annotation.key()})
get_owns_overridden
get_owns_overridden(transaction: TypeDBTransaction, attribute_type: AttributeType) -> Promise[AttributeType | None]
Retrieves an AttributeType
, ownership of which is overridden for this ThingType
by a given attribute_type
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The |
|
Promise[AttributeType | None]
thing_type.get_owns_overridden(transaction, attribute_type).resolve()
get_plays
get_plays(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[RoleType]
Retrieves all direct and inherited (or direct only) roles that are allowed to be played by the instances of this ThingType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[RoleType]
thing_type.get_plays(transaction)
thing_type.get_plays(transaction, Transitivity.EXPLICIT)
get_plays_overridden
get_plays_overridden(transaction: TypeDBTransaction, role_type: RoleType) -> Promise[RoleType | None]
Retrieves a RoleType
that is overridden by the given role_type
for this ThingType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The |
|
Promise[RoleType | None]
thing_type.get_plays_overridden(transaction, role_type).resolve()
get_subtypes
get_subtypes(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[ThingType]
Retrieves all direct and indirect (or direct only) subtypes of the ThingType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[ThingType]
thing_type.get_subtypes(transaction)
thing_type.get_subtypes(transaction, Transitivity.EXPLICIT)
get_supertype
get_supertype(transaction: TypeDBTransaction) -> Promise[ThingType | None]
Retrieves the most immediate supertype of the ThingType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[ThingType | None]
thing_type.get_supertype(transaction).resolve()
get_supertypes
get_supertypes(transaction: TypeDBTransaction) -> Iterator[ThingType]
Retrieves all supertypes of the ThingType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Iterator[ThingType]
thing_type.get_supertypes(transaction)
get_syntax
get_syntax(transaction: TypeDBTransaction) -> Promise[str]
Produces a pattern for creating this ThingType
in a define
query.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[str]
thing_type.get_syntax(transaction).resolve()
is_thing_type
is_thing_type() -> bool
Checks if the concept is a ThingType
.
bool
thing_type.is_thing_type()
set_abstract
set_abstract(transaction: TypeDBTransaction) -> Promise[None]
Set a ThingType
to be abstract, meaning it cannot have instances.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[None]
thing_type.set_abstract(transaction).resolve()
set_owns
set_owns(transaction: TypeDBTransaction, attribute_type: AttributeType, overridden_type: AttributeType | None = None, annotations: set[Annotation] | None = None) -> Promise[None]
Allows the instances of this ThingType
to own the given AttributeType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The |
|
|
|
The |
|
|
|
Adds annotations to the ownership. |
|
|
Promise[None]
thing_type.set_owns(transaction, attribute_type).resolve()
thing_type.set_owns(transaction, attribute_type,
overridden_type=overridden_type,
annotations={Annotation.key()}).resolve()
set_plays
set_plays(transaction: TypeDBTransaction, role_type: RoleType, overriden_type: RoleType | None = None) -> Promise[None]
Allows the instances of this ThingType
to play the given role.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The role to be played by the instances of this type |
|
|
|
The role type that this role overrides, if applicable |
|
|
Promise[None]
thing_type.set_plays(transaction, role_type).resolve()
thing_type.set_plays(transaction, role_type, overridden_type).resolve()
unset_abstract
unset_abstract(transaction: TypeDBTransaction) -> Promise[None]
Set a ThingType
to be non-abstract, meaning it can have instances.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[None]
thing_type.unset_abstract(transaction).resolve()
unset_owns
unset_owns(transaction: TypeDBTransaction, attribute_type: AttributeType) -> Promise[None]
Disallows the instances of this ThingType
from owning the given AttributeType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The |
|
Promise[None]
thing_type.unset_owns(transaction, attribute_type).resolve()
unset_plays
unset_plays(transaction: TypeDBTransaction, role_type: RoleType) -> Promise[None]
Disallows the instances of this ThingType
from playing the given role.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The role to not be played by the instances of this type. |
|
Promise[None]
thing_type.unset_plays(transaction, role_type).resolve()
EntityType
Supertypes:
-
ThingType
Entity types represent the classification of independent objects in the data model of the business domain.
as_entity_type
as_entity_type() -> EntityType
Casts the concept to EntityType
.
EntityType
entity_type.as_entity_type()
create
create(transaction: TypeDBTransaction) -> Promise[Entity]
Creates and returns a new instance of this EntityType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[Entity]
entity_type.create(transaction).resolve()
get_instances
get_instances(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[Entity]
Retrieves all direct and indirect (or direct only) Entity
objects that are instances of this EntityType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[Entity]
entity_type.get_instances(transaction, transitivity)
get_subtypes
get_subtypes(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[EntityType]
Retrieves all direct and indirect (or direct only) subtypes of the EntityType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[EntityType]
entity_type.get_subtypes(transaction, transitivity)
is_entity_type
is_entity_type() -> bool
Checks if the concept is an EntityType
.
bool
entity_type.is_entity_type()
set_supertype
set_supertype(transaction: TypeDBTransaction, super_entity_type: EntityType) -> Promise[None]
Sets the supplied EntityType
as the supertype of the current EntityType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The |
|
Promise[None]
entity_type.set_supertype(transaction, super_entity_type).resolve()
RelationType
Supertypes:
-
ThingType
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.
as_relation_type
as_relation_type() -> RelationType
Casts the concept to RelationType
.
RelationType
relation_type.as_relation_type()
create
create(transaction: TypeDBTransaction) -> Promise[Relation]
Creates and returns an instance of this RelationType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[Relation]
relation_type.create(transaction).resolve()
get_instances
get_instances(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[Relation]
Retrieves all direct and indirect (or direct only) Relation
s that are instances of this RelationType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[Relation]
relation_type.get_instances(transaction, transitivity)
get_relates
get_relates(transaction: TypeDBTransaction, role_label: str | None = None, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Promise[RoleType | None] | Iterator[RoleType]
Retrieves roles that this RelationType
relates to directly or via inheritance. If role_label
is given, returns a corresponding RoleType
or None
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
Label of the role we wish to retrieve (optional) |
|
|
|
|
|
|
Promise[RoleType | None] | Iterator[RoleType]
relation_type.get_relates(transaction, role_label, transitivity).resolve()
relation_type.get_relates(transaction, transitivity)
get_relates_overridden
get_relates_overridden(transaction: TypeDBTransaction, role_label: str) -> Promise[RoleType | None]
Retrieves a RoleType
that is overridden by the role with the role_label
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
Label of the role that overrides an inherited role |
|
Promise[RoleType | None]
relation_type.get_relates_overridden(transaction, role_label).resolve()
get_subtypes
get_subtypes(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[RelationType]
Retrieves all direct and indirect (or direct only) subtypes of the RelationType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[RelationType]
relation_type.get_subtypes(transaction, transitivity)
is_relation_type
is_relation_type() -> bool
Checks if the concept is a RelationType
.
bool
relation_type.is_relation_type()
set_relates
set_relates(transaction: TypeDBTransaction, role_label: str, overridden_label: str | None = None) -> Promise[None]
Sets the new role that this RelationType
relates to. If we are setting an overriding type this way, we have to also pass the overridden type as a second argument.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The new role for the |
|
|
|
The label being overridden, if applicable |
|
|
Promise[None]
relation_type.set_relates(transaction, role_label).resolve()
relation_type.set_relates(transaction, role_label, overridden_label).resolve()
set_supertype
set_supertype(transaction: TypeDBTransaction, super_relation_type: RelationType) -> Promise[None]
Sets the supplied RelationType
as the supertype of the current RelationType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The |
|
Promise[None]
relation_type.set_supertype(transaction, super_relation_type).resolve()
unset_relates
unset_relates(transaction: TypeDBTransaction, role_label: str) -> Promise[None]
Disallows this RelationType
from relating to the given role.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The role to not relate to the relation type. |
|
Promise[None]
relation_type.unset_relates(transaction, role_label).resolve()
RoleType
Supertypes:
-
Type
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.
as_role_type
as_role_type() -> RoleType
Casts the concept to RoleType
.
RoleType
role_type.as_role_type()
get_player_instances
get_player_instances(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[Thing]
Retrieves the Thing
instances that play this role.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[Thing]
role_type.get_player_instances(transaction, transitivity)
get_player_types
get_player_types(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[ThingType]
Retrieves the ThingType
s whose instances play this role.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[ThingType]
role_type.get_player_types(transaction, transitivity)
get_relation_instances
get_relation_instances(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[Relation]
Retrieves the Relation
instances that this role is related to.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[Relation]
role_type.get_relation_instances(transaction, transitivity)
get_relation_type
get_relation_type(transaction: TypeDBTransaction) -> Promise[RelationType]
Retrieves the RelationType
that this role is directly related to.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[RelationType]
role_type.get_relation_type(transaction).resolve()
get_relation_types
get_relation_types(transaction: TypeDBTransaction) -> Iterator[RelationType]
Retrieves RelationType
s that this role is related to (directly or indirectly).
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Iterator[RelationType]
role_type.get_relation_types(transaction)
get_subtypes
get_subtypes(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[RoleType]
Retrieves all direct and indirect (or direct only) subtypes of the RoleType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[RoleType]
role_type.get_subtypes(transaction, transitivity)
get_supertype
get_supertype(transaction: TypeDBTransaction) -> Promise[RoleType | None]
Retrieves the most immediate supertype of the RoleType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[RoleType | None]
role_type.get_supertype(transaction).resolve()
get_supertypes
get_supertypes(transaction: TypeDBTransaction) -> Iterator[RoleType]
Retrieves all supertypes of the RoleType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Iterator[RoleType]
role_type.get_supertypes(transaction)
AttributeType
Supertypes:
-
ThingType
Attribute types represent properties that other types can own.
Attribute 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.
as_attribute_type
as_attribute_type() -> AttributeType
Casts the concept to AttributeType
.
AttributeType
attribute.as_attribute_type()
get
get(transaction: TypeDBTransaction, value: Value | bool | int | float | str | datetime) -> Promise[Attribute | None]
Retrieves an Attribute
of this AttributeType
with the given value if such Attribute
exists. Otherwise, returns None
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
Promise[Attribute | None]
attribute = attribute_type.get(transaction, value).resolve()
get_instances
get_instances(transaction: TypeDBTransaction, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[Attribute]
Retrieves all direct and indirect (or direct only) Attributes
that are instances of this AttributeType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
Iterator[Attribute]
attribute_type.get_instances(transaction)
attribute_type.get_instances(transaction, Transitivity.EXPLICIT)
get_owners
get_owners(transaction: TypeDBTransaction, annotations: set[Annotation] | None = None, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[ThingType]
Retrieve all Things
that own an attribute of this AttributeType
. Optionally, filtered by Annotation
s.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
Only retrieve |
|
|
|
|
|
|
Iterator[ThingType]
attribute_type.get_owners(transaction)
attribute_type.get_owners(transaction, annotations=Annotation.unique(), transitivity=Transitivity.EXPLICIT)
get_regex
get_regex(transaction: TypeDBTransaction) -> Promise[str]
Retrieves the regular expression that is defined for this AttributeType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[str]
attribute_type.get_regex(transaction).resolve()
get_subtypes_with_value_type
get_subtypes_with_value_type(transaction: TypeDBTransaction, value_type: ValueType, transitivity: Transitivity = Transitivity.TRANSITIVE) -> Iterator[AttributeType]
Retrieves all direct and indirect (or direct only) subtypes of this AttributeType
with given ValueType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
|
|
|
|
|
|
|
Iterator[AttributeType]
attribute_type.get_subtypes_with_value_type(transaction, value_type)
attribute_type.get_subtypes_with_value_type(transaction, value_type,
Transitivity.EXPLICIT)
get_value_type
get_value_type() -> ValueType
Retrieves the ValueType
of this AttributeType
.
ValueType
attribute_type.get_value_type()
is_attribute_type
is_attribute_type() -> bool
Checks if the concept is an AttributeType
.
bool
attribute.is_attribute_type()
is_boolean
is_boolean() -> bool
Returns True
if the value for attributes of this type is of type boolean
. Otherwise, returns False
.
bool
attribute_type.is_boolean()
is_datetime
is_datetime() -> bool
Returns True
if the value for attributes of this type is of type datetime
. Otherwise, returns False
.
bool
attribute_type.is_datetime()
is_double
is_double() -> bool
Returns True
if the value for attributes of this type is of type double
. Otherwise, returns False
.
bool
attribute_type.is_double()
is_long
is_long() -> bool
Returns True
if the value for attributes of this type is of type long
. Otherwise, returns False
.
bool
attribute_type.is_long()
is_string
is_string() -> bool
Returns True
if the value for attributes of this type is of type string
. Otherwise, returns False
.
bool
attribute_type.is_string()
put
put(transaction: TypeDBTransaction, value: Value | bool | int | float | str | datetime) -> Promise[Attribute]
Adds and returns an Attribute
of this AttributeType
with the given value.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
New |
|
Promise[Attribute]
attribute = attribute_type.put(transaction, value).resolve()
set_regex
set_regex(transaction: TypeDBTransaction, regex: str) -> Promise[None]
Sets a regular expression as a constraint for this AttributeType
. Values
of all Attribute
s of this type (inserted earlier or later) should match this regex.
Can only be applied for AttributeType
s with a string
value type.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
Regular expression |
|
Promise[None]
attribute_type.set_regex(transaction, regex).resolve()
set_supertype
set_supertype(transaction: TypeDBTransaction, super_attribute_type: AttributeType) -> Promise[None]
Sets the supplied AttributeType
as the supertype of the current AttributeType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The |
|
Promise[None]
attribute_type.set_supertype(transaction, super_attribute_type).resolve()
unset_regex
unset_regex(transaction: TypeDBTransaction) -> Promise[None]
Removes the regular expression that is defined for this AttributeType
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[None]
attribute_type.unset_regex(transaction).resolve()
Annotation
is_key
is_key() -> bool
Checks if this Annotation
is a @key
annotation.
bool
annotation.is_key()
is_unique
is_unique() -> bool
Checks if this Annotation
is a @unique
annotation.
bool
annotation.is_unique()
Transitivity
This class is used for specifying whether we need explicit or transitive subtyping, instances, etc.
attribute_type.get_owners(transaction, annotations=annotations, transitivity=Transitivity.EXPLICIT)
Name | Value |
---|---|
|
|
|
|
ValueType
TypeQL value types for attributes and value concepts.
Name | Value |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Data
Thing
Supertypes:
-
Concept
as_thing
as_thing() -> Thing
Casts the concept to Thing
.
Thing
thing.as_thing()
delete
delete(transaction: TypeDBTransaction) -> Promise[None]
Deletes this Thing
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[None]
thing.delete(transaction).resolve()
get_has
get_has(transaction: TypeDBTransaction, attribute_type: AttributeType = None, attribute_types: list[AttributeType] = None, annotations: set[Annotation] = frozenset({})) -> Iterator[Attribute]
Retrieves the Attribute
s that this Thing
owns. Optionally, filtered by an AttributeType
or a list of AttributeType
s. Optionally, filtered by Annotation
s.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The |
|
|
|
The |
|
|
|
Only retrieve attributes with all given |
|
|
Iterator[Attribute]
thing.get_has(transaction)
thing.get_has(transaction, attribute_type=attribute_type,
annotations=set(Annotation.key()))
get_iid
get_iid() -> str
Retrieves the unique id of the Thing
.
str
thing.get_iid()
get_playing
get_playing(transaction: TypeDBTransaction) -> Iterator[RoleType]
Retrieves the roles that this Thing
is currently playing.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Iterator[RoleType]
thing.get_playing(transaction)
get_relations
get_relations(transaction: TypeDBTransaction, *role_types: RoleType) -> Iterator[Relation]
Retrieves all the Relation
s which this Thing
plays a role in, optionally filtered by one or more given roles.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
0 or more role types to filter the relations by. |
|
Iterator[Relation]
thing.get_relations(transaction, role_types)
get_type
get_type() -> ThingType
Retrieves the type which this Thing
belongs to.
ThingType
thing.get_type()
is_deleted
is_deleted(transaction: TypeDBTransaction) -> Promise[bool]
Checks if this Thing
is deleted.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Promise[bool]
thing.is_deleted(transaction).resolve()
is_inferred
is_inferred() -> bool
Checks if this Thing
is inferred by a [Reasoning Rule].
bool
thing.is_inferred()
is_thing
is_thing() -> bool
Checks if the concept is a Thing
.
bool
thing.is_thing()
set_has
set_has(transaction: TypeDBTransaction, attribute: Attribute) -> Promise[None]
Assigns an Attribute
to be owned by this Thing
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The |
|
Promise[None]
thing.set_has(transaction, attribute).resolve()
unset_has
unset_has(transaction: TypeDBTransaction, attribute: Attribute) -> Promise[None]
Unassigns an Attribute
from this Thing
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The |
|
Promise[None]
thing.unset_has(transaction, attribute).resolve()
Entity
Supertypes:
-
Thing
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.
as_entity
as_entity() -> Entity
Casts the concept to Entity
.
Entity
entity.as_entity()
Relation
Supertypes:
-
Thing
Relation is an instance of a relation type and can be uniquely addressed by a combination of its type, owned attributes and role players.
add_player
add_player(transaction: TypeDBTransaction, role_type: RoleType, player: Thing) -> Promise[None]
Adds a new role player to play the given role in this Relation
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The role to be played by the |
|
|
|
The thing to play the role |
|
Promise[None]
relation.add_player(transaction, role_type, player).resolve()
as_relation
as_relation() -> Relation
Casts the concept to Relation
.
Relation
relation.as_relation()
get_players
get_players(transaction: TypeDBTransaction) -> dict[RoleType, list[Thing]]
Retrieves a mapping of all instances involved in the Relation
and the role each play.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
dict[RoleType, list[Thing]]
relation.get_players(transaction)
get_players_by_role_type
get_players_by_role_type(transaction: TypeDBTransaction, *role_types: RoleType) -> Iterator[Thing]
Retrieves all role players of this Relation
, optionally filtered by given role types.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
0 or more role types |
|
Iterator[Thing]
relation.get_players_by_role_type(transaction)
relation.get_players_by_role_type(transaction, role_type1, role_type2)
get_relating
get_relating(transaction: TypeDBTransaction) -> Iterator[RoleType]
Retrieves all role types currently played in this Relation
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
Iterator[RoleType]
relation.get_relating(transaction)
get_type
get_type() -> RelationType
Retrieves the type which this Relation
belongs to.
RelationType
relation.get_type()
is_relation
is_relation() -> bool
Checks if the concept is a Relation
.
bool
relation.is_relation()
remove_player
remove_player(transaction: TypeDBTransaction, role_type: RoleType, player: Thing) -> Promise[None]
Removes the association of the given instance that plays the given role in this Relation
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
The role to no longer be played by the thing in this |
|
|
|
The instance to no longer play the role in this |
|
Promise[None]
relation.remove_player(transaction, role_type, player).resolve()
Attribute
Supertypes:
-
Thing
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.
as_attribute
as_attribute() -> Attribute
Casts the concept to Attribute
.
Attribute
attribute.as_attribute()
as_boolean
as_boolean() -> bool
Returns a boolean
value of the attribute. If the value has another type, raises an exception.
bool
attribute.as_boolean()
as_datetime
as_datetime() -> datetime
Returns a datetime
value of the attribute. If the value has another type, raises an exception.
datetime
attribute.as_boolean()
as_double
as_double() -> float
Returns a double
value of the attribute. If the value has another type, raises an exception.
float
attribute.as_boolean()
as_long
as_long() -> int
Returns a long
value of the attribute. If the value has another type, raises an exception.
int
attribute.as_long()
as_string
as_string() -> str
Returns a string
value of the attribute. If the value has another type, raises an exception.
str
attribute.as_boolean()
get_owners
get_owners(transaction: TypeDBTransaction, owner_type: ThingType | None = None) -> Iterator[Thing]
Retrieves the instances that own this Attribute
.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current transaction |
|
|
|
If specified, filter results for only owners of the given type |
|
|
Iterator[Thing]
attribute.get_owners(transaction)
attribute.get_owners(transaction, owner_type)
get_type
get_type() -> AttributeType
Retrieves the type which this Attribute
belongs to.
AttributeType
attribute.get_type()
get_value
get_value() -> bool | int | float | str | datetime
Retrieves the value which the Attribute
instance holds.
bool | int | float | str | datetime
attribute.get_value()
get_value_type
get_value_type() -> ValueType
Retrieves the type of the value which the Attribute
instance holds.
ValueType
attribute.get_value_type()
is_attribute
is_attribute() -> bool
Checks if the concept is an Attribute
.
bool
attribute.is_attribute()
is_boolean
is_boolean() -> bool
Returns True
if the attribute value is of type boolean
. Otherwise, returns False
.
bool
attribute.is_boolean()
is_datetime
is_datetime() -> bool
Returns True
if the attribute value is of type datetime
. Otherwise, returns False
.
bool
attribute.is_datetime()
is_double
is_double() -> bool
Returns True
if the attribute value is of type double
. Otherwise, returns False
.
bool
attribute.is_double()
Value
Supertypes:
-
Concept
as_boolean
as_boolean() -> bool
Returns a boolean
value of this value concept. If the value has another type, raises an exception.
bool
value.as_boolean()
as_datetime
as_datetime() -> datetime
Returns a timezone naive datetime
value of this value concept. If the value has another type, raises an exception.
datetime
value.as_datetime()
as_double
as_double() -> float
Returns a double
value of this value concept. If the value has another type, raises an exception.
float
value.as_double()
as_long
as_long() -> int
Returns a long
value of this value concept. If the value has another type, raises an exception.
int
value.as_long()
as_string
as_string() -> str
Returns a string
value of this value concept. If the value has another type, raises an exception.
str
value.as_string()
as_value
as_value() -> Value
Casts the concept to Value
.
Value
value.as_value()
get
get() -> bool | int | float | str | datetime
Retrieves the value which this value concept holds.
bool | int | float | str | datetime
value.get()
get_value_type
get_value_type() -> ValueType
Retrieves the ValueType
of this value concept.
ValueType
value.get_value_type()
is_boolean
is_boolean() -> bool
Returns True
if the value which this value concept holds is of type boolean
. Otherwise, returns False
.
bool
value.is_boolean()
is_datetime
is_datetime() -> bool
Returns True
if the value which this value concept holds is of type datetime
. Otherwise, returns False
.
bool
value.is_datetime()
is_double
is_double() -> bool
Returns True
if the value which this value concept holds is of type double
. Otherwise, returns False
.
bool
value.is_double()
is_long
is_long() -> bool
Returns True
if the value which this value concept holds is of type long
. Otherwise, returns False
.
bool
value.is_long()
Logic
LogicManager
Provides methods for manipulating rules in the database.
get_rule
get_rule(label: str) -> Promise[Rule | None]
Retrieves the Rule that has the given label.
Name | Description | Type | Default Value |
---|---|---|---|
|
The label of the Rule to create or retrieve |
|
Promise[Rule | None]
transaction.logic.get_rule(label).resolve()
get_rules
get_rules() -> Iterator[Rule]
Retrieves all rules.
Iterator[Rule]
transaction.logic.get_rules()
put_rule
put_rule(label: str, when: str, then: str) -> Promise[Rule]
Creates a new Rule if none exists with the given label, or replaces the existing one.
Name | Description | Type | Default Value |
---|---|---|---|
|
The label of the Rule to create or replace |
|
|
|
The when body of the rule to create |
|
|
|
The then body of the rule to create |
|
Promise[Rule]
transaction.logic.put_rule(label, when, then).resolve()
Rule
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.
Name | Type | Description |
---|---|---|
|
|
The unique label of the rule. |
|
|
The single statement that constitutes the ‘then’ of the rule. |
|
|
The statements that constitute the ‘when’ of the rule. |
delete
delete(transaction: TypeDBTransaction) -> Promise[None]
Deletes this rule.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current |
|
Promise[None]
rule.delete(transaction).resolve()
is_deleted
is_deleted(transaction: TypeDBTransaction) -> Promise[bool]
Check if this rule has been deleted.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current |
|
Promise[bool]
rule.is_deleted(transaction).resolve()
set_label
set_label(transaction: TypeDBTransaction, new_label: str) -> Promise[None]
Renames the label of the rule. The new label must remain unique.
Name | Description | Type | Default Value |
---|---|---|---|
|
The current |
|
|
|
The new label to be given to the rule |
|
Promise[None]
rule.set_label(transaction, new_label).resolve()