Edit on Github

Type Methods

Type has all the Concept methods plus what follows.

[tab:Java]

Retrieve label

type.label();

Returns

String

Rename label

type.label(Label.of(String label));

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

Accepts

Param Description Type Required Default

label

The new label to be given to the type.

String

true

N/A

Returns

Type object

Retrieve direct supertype

type.sup();

Retrieves the most immidiate supertype of the type.

Returns

Type object

|

NULL

Retrieve all supertypes

type.sups();

Retrieves all supertypes of the type.

Returns

Stream of Type objects

Retrieve all subtypes

type.subs();

Retrieves all indirect subtypes of the type.

Returns

Stream of Type objects

Check if type is implicit

type.isImplicit();

Checks if the type has been created, under the hood, by Grakn (i.e. implicit).

Returns

boolean

Check if type is abstract

type.isAbstract();

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

Returns

boolean

Toggle abstraction

type.isAbstract(Boolean abstract);

Determines whether or not there can be instances of this type.

Accepts

Param Description Type Required Default

abstract

true to be abstracted and false to not.

boolean

true

N/A

Returns

Type object

Retrieve roles

type.playing();

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

Returns

Stream of Role objects

Add new role

type.plays(Role role);

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

Accepts

Param Description Type Required Default

role

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

Role

true

N/A

Returns

Type object

Remove role

type.unplay(Role role);

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

Accepts

Param Description Type Required Default

role

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

Role

true

N/A

Returns

Type object

Retrieve attributes

type.attributes();

Retrieves attributes that the instances of this type are allowed to own.

Returns

Stream of AttributeType objects

Add attribute

type.has(AttributeType attributeType);

Allows the instances of this type to own the given AttributeType.

Accepts

Param Description Type Required Default

attributeType

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

AttributeType

true

N/A

Returns

Type object

Remove attribute

type.unhas(AttributeType attributeType);

Disallows the instances of this type from owning the given AttributeType.

Accepts

Param Description Type Required Default

attributeType

The AttributeType to not be owend by the type.

AttributeType

true

N/A

Returns

Type object

Retrieve keys

type.keys();

Returns

Stream of AttributeType objects

Add key

type.key(AttributeType attributeType);

Allows the instances of this type to own the given AttributeType as their key.

Accepts

Param Description Type Required Default

key

The AttributeType to be owned by the instances of this type as their key.

AttributeType

true

N/A

Returns

Type object

Remove key

type.unkey(AttributeType key);

Disallows the instances of this type from owning the given AttributeType as its key.

Accepts

Param Description Type Required Default

attributeType

the AttributeType to not be owend by the instances of this type as their key.

AttributeType

true

N/A

Returns

Type object

Retrieve instances

type.instances();

Returns

Stream of Thing objects

[tab:end] [tab:Javascript]

Retrieve label

await type.label();

Returns

String

Rename label

await type.label(label);

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

Accepts

Param Description Type Required Default

label

The new label to be given to the type.

String

true

N/A

Returns

void

Retrieve direct supertype

await type.sup();

Retrieves the most immidiate supertype of the type.

Returns

Type object

|

null

Change direct supertype

await type.sup(type)

Changes the most immidiete supertype of the type.

Accepts

Param Description Type Required Default

type

The new type that the given type is to inherits.

EntityType | AttributeType | RelationType

true

N/A

Returns

void

Retrieve all supertypes

await type.sups()

Retrieves all supertypes of the type.

Returns

Iterator of Type objects

Retrieve all subtypes

await type.subs()

Retrieves all indirect subtypes of the type.

Returns

Iterator of Type objects

Check if type is implicit

await type.isImplicit();

Checks if the type has been created, under the hood, by Grakn (i.e. implicit).

Returns

boolean

Check if type is abstract

await type.isAbstract();

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

Returns

boolean

Toggle abstraction

await type.isAbstract(abstract);

Determines whether or not there can be instances of this type.

Accepts

Param Description Type Required Default

abstract

true to be abstracted and false to not.

boolean

true

N/A

Returns

void

Retrieve roles

await type.playing();

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

Returns

Iterator of Role objects

Add new role

await type.plays(role);

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

Accepts

Param Description Type Required Default

role

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

Role

true

N/A

Returns

void

Remove role

await type.unplay(role);

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

Accepts

Param Description Type Required Default

role

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

Role

true

N/A

Returns

void

Retrieve attributes

await type.attributes();

Retrieves attributes that the instances of this type are allowed to own.

Returns

Iterator of AttributeType objects

Add attribute

await type.has(attributeType);

Allows the instances of this type to own the given AttributeType.

Accepts

Param Description Type Required Default

attributeType

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

AttributeType

true

N/A

Returns

void

Remove attribute

await type.unhas(attributeType);

Disallows the instances of this type from owning the given AttributeType.

Accepts

Param Description Type Required Default

attributeType

The AttributeType to not be owend by the type.

AttributeType

true

N/A

Returns

void

Retrieve keys

await type.keys();

Returns

Iterator of AttributeType objects

Add key

await type.key(attributeType);

Allows the instances of this type to own the given AttributeType as their key.

Accepts

Param Description Type Required Default

key

The AttributeType to be owned by the instances of this type as their key.

AttributeType

true

N/A

Returns

void

Remove key

await type.unkey(attributeType);

Disallows the instances of this type from owning the given AttributeType as its key.

Accepts

Param Description Type Required Default

attributeType

the AttributeType to not be owend by the instances of this type as their key.

AttributeType

true

N/A

Returns

void

Retrieve instances

await type.instances();

Returns

Iterator of Thing objects

[tab:end] [tab:Python]

Retrieve label

type.label()

Returns

String

Rename label

type.label(label)

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

Accepts

Param Description Type Required Default

label

The new label to be given to the type.

String

true

N/A

Returns

Type object

Retrieve direct supertype

type.sup()

Retrieves the most immidiate supertype of the type.

Returns

Type object

|

None

Change direct supertype

type.sup(type)

Changes the most immidiete supertype of the type.

Accepts

Param Description Type Required Default

type

The new type that the given type is to inherits.

EntityType | AttributeType | RelationType

true

N/A

Returns

Type object

|

None

Retrieve all supertypes

type.sups()

Retrieves all supertypes of the type.

Returns

Iterator of Type objects

Retrieve all subtypes

type.subs()

Retrieves all indirect subtypes of the type.

Returns

Iterator of Type objects

Check if type is implicit

type.is_implicit()

Checks if the type has been created, under the hood, by Grakn (i.e. implicit).

Returns

boolean

Check if type is abstract

type.is_abstract()

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

Returns

boolean

Toggle abstraction

type.is_abstract(abstract)

Determines whether or not there can be instances of this type.

Accepts

Param Description Type Required Default

abstract

true to be abstracted and false to not.

boolean

true

N/A

Returns

Type object

Retrieve roles

type.playing()

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

Returns

Iterator of Role objects

Add new role

type.plays(role)

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

Accepts

Param Description Type Required Default

role

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

Role

true

N/A

Returns

Type object

Remove role

type.unplay(role)

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

Accepts

Param Description Type Required Default

role

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

Role

true

N/A

Returns

Type object

Retrieve attributes

type.attributes()

Retrieves attributes that the instances of this type are allowed to own.

Returns

Iterator of AttributeType objects

Add attribute

type.has(attribute_type)

Allows the instances of this type to own the given AttributeType.

Accepts

Param Description Type Required Default

attribute_type

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

AttributeType

true

N/A

Returns

Type object

Remove attribute

type.unhas(attribute_type)

Disallows the instances of this type from owning the given AttributeType.

Accepts

Param Description Type Required Default

attribute_type

The AttributeType to not be owend by the type.

AttributeType

true

N/A

Returns

Type object

Retrieve keys

type.keys()

Returns

Iterator of AttributeType objects

Add key

type.key(attributeType)

Allows the instances of this type to own the given AttributeType as their key.

Accepts

Param Description Type Required Default

key

The AttributeType to be owned by the instances of this type as their key.

AttributeType

true

N/A

Returns

Type object

Remove key

type.unkey(attribute_type)

Disallows the instances of this type from owning the given AttributeType as its key.

Accepts

Param Description Type Required Default

attribute_type

the AttributeType to not be owend by the instances of this type as their key.

AttributeType

true

N/A

Returns

Type object

Retrieve instances

type.instances()

Returns

Iterator of Thing objects

[tab:end]

EntityType Methods

EntityType has all the Type methods plus what follows.

[tab:Java]

Create instance

entityType.create();

Creates and returns a new instance of this EntityType.

Returns

Entity object

[tab:end] [tab:Javascript]

Create instance

await entityType.create();

Creates and returns a new instance of this EntityType.

Returns

Entity object

[tab:end] [tab:Python]

Create instance

entity_type.create()

Creates and returns a new instance of this EntityType.

Returns

Entity object

[tab:end]

AttributeType Methods

AttributeType has all the Type methods plus what follows.

[tab:Java]

Create instance

attributeType.create(Object value);

Creates and returns a new instance of this AttributeType with the given value.

Accepts

Param Description Type Required Default

value

The value for the new attribute instance to hold.

String | boolean | long | double | Date

true

N/A

Returns

Attribute object

Retrieve instance by value

attributeType.attribute(Object value);

Retrieves the instance of this AttributeType with the given value.

Accepts

Param Description Type Required Default

value

The value for the instance of this AttributeType to retrieve.

String | boolean | integer | float | date

true

N/A

Returns

Attribute object

|

NULL

Retrieve datatype

attributeType.dataType();

Retrieves the datatype given to this AttributeType.

Returns

String

Retrieve regex

attributeType.regex();

Retrieves the regex that all instances of this AttributeType must conform to.

Returns

String

|

NULL

Set regex

attributeType.regex(String regex);

Set the regex that all instances of this AttributeType must conform to.

Accepts

Param Description Type Required Default

regex

The regex that all instances of this AttributeType must conform to.

String

true

N/A

Returns

AttributeType object

[tab:end] [tab:Javascript]

Create instance

await attributeType.create(value);

Creates and returns a new instance of this AttributeType with the given value.

Accepts

Param Description Type Required Default

value

The value for the new attribute instance to hold.

String | boolean | integer | float | date

true

N/A

Returns

Attribute object

Retrieve instance by value

await attributeType.attribute(value);

Retrieves the instance of this AttributeType with the given value.

Accepts

Param Description Type Required Default

value

The value for the instance of this AttributeType to retrieve.

String | boolean | integer | float | date

true

N/A

Returns

Attribute object

|

null

Retrieve datatype

await attributeType.dataType();

Retrieves the datatype given to this AttributeType.

Returns

String

Retrieve regex

await attributeType.regex();

Retrieves the regex that all instances of this AttributeType must conform to.

Returns

String

|

None

Set regex

await attributeType.regex(regex);

Set the regex that all instances of this AttributeType must conform to.

Accepts

Param Description Type Required Default

regex

The regex that all instances of this AttributeType must conform to.

String

true

N/A

Returns

void

[tab:end] [tab:Python]

Create instance

attribute_type.create(value)

Creates and returns a new instance of this AttributeType with the given value.

Accepts

Param Description Type Required Default

value

The value for the new attribute instance to hold.

String | boolean | integer | float | date

true

N/A

Returns

Attribute object

Retrieve instance by value

attribute_type.attribute(value)

Retrieves the instance of this AttributeType with the given value.

Accepts

Param Description Type Required Default

value

The value for the instance of this AttributeType to retrieve.

String | boolean | integer | float | date

true

N/A

Returns

Attribute object

|

None

Retrieve datatype

attributeType.data_type()

Retrieves the datatype given to this AttributeType.

Returns

String

Retrieve regex

attribute_type.regex()

Retrieves the regex that all instances of this AttributeType must conform to.

Returns

String

|

null

Set regex

attribute_type.regex(regex)

Set the regex that all instances of this AttributeType must conform to.

Accepts

Param Description Type Required Default

regex

The regex that all instances of this AttributeType must conform to.

String

true

N/A

Returns

AttributeType object

[tab:end]

RelationType Methods

RelationType has all the Type methods plus what follows.

[tab:Java]

Create instance

relationType.create();

Creates and returns an instance of this RelationType.

Returns

Relation object

Retrieve roles

relationType.roles();

Retrieve roles that this RelationType relates to.

Returns

Stream of Role objects

Set new role

relationType.relates(Role role);

Sets the new role that this RelationType relates to.

Accepts

Param Description Type Required Default

role

The new role for the RelationType to relate to.

Role

true

N/A

Returns

RelationType object

Remove role

relationType.unrelate(Role role);

Disallows this RelationType from relating to the given role.

Accepts

Param Description Type Required Default

role

The role to not relate to the relation type.

Role

true

N/A

Returns

RelationType object

[tab:end] [tab:Javascript]

Create instance

await relationType.create();

Creates and returns an instance of this RelationType.

Returns

Relation object

Retrieve roles

await relationType.roles();

Retrieve roles that this RelationType relates to.

Returns

Iterator of Role objects

Set new role

await relationType.relates(role);

Sets the new role that this RelationType relates to.

Accepts

Param Description Type Required Default

role

The new role for the RelationType to relate to.

Role

true

N/A

Returns

void

Remove role

await relationType.unrelate(role);

Disallows this RelationType from relating to the given role.

Accepts

Param Description Type Required Default

role

The role to not relate to the relation type.

Role

true

N/A

Returns

void

[tab:end] [tab:Python]

Create instance

relation_type.create()

Creates and returns an instance of this RelationType.

Returns

Relation object

Retrieve roles

relation_type.roles()

Retrieve roles that this RelationType relates to.

Returns

Iterator of Role objects

Set new role

relation_type.relates(role)

Sets the new role that this RelationType relates to.

Accepts

Param Description Type Required Default

role

The new role for the RelationType to relate to.

Role

true

N/A

Returns

RelationType object

Remove role

relation_type.unrelate(role)

Disallows this RelationType from relating to the given role.

Accepts

Param Description Type Required Default

role

The role to not relate to the relation type.

Role

true

N/A

Returns

RelationType object

[tab:end]

Role Methods

Role has all the Concept methods plus what follows.

[tab:Java]
[Important] At the moment, `Role` inherits an intermediary class which, for the sake of simplicity, has not been documented. Therefore, besides the `Concept` methods, Role inherits the following methods from the `Type` class. - [label();](?tab=java#retrieve-label) - [type.label(Label.of(label));](?tab=java#rename-label) - [sup();](?tab=java#retrieve-direct-supertype) - [sup(Type type);](?tab=java#change-direct-supertype) - [sups();](?tab=java#retrieve-all-supertypes) - [subs();](?tab=java#retrieve-all-subtypes)

Retrieve relations

role.relations();

Retrieves the Relation instances that this role is related to.

Returns

Stream of Relation objects

Retrieve roleplayers

role.players();

Retrieves the Types whose instances play this role.

Returns

Stream of Type objects

[tab:end] [tab:Javascript]
[Important] At the moment, `Role` inherits an intermediary class which, for the sake of simplicity, has not been documented. Therefore, besides the `Concept` methods, Role inherits the following methods from the `Type` class. - [label();](?tab=javascript#retrieve-label) - [type.label(Label.of(label));](?tab=javascript#rename-label) - [sup();](?tab=javascript#retrieve-direct-supertype) - [sup(Type type);](?tab=javascript#change-direct-supertype) - [sups();](?tab=javascript#retrieve-all-supertypes) - [subs();](?tab=javascript#retrieve-all-subtypes)

Retrieve relations

await role.relations();

Retrieves the Relation instances that this role is related to.

Returns

Iterator of `Relation objects

Retrieve roleplayers

await role.players();

Retrieves the Types whose instances play this role.

Returns

Iterator of Type objects

[tab:end] [tab:Python]
[Important] At the moment, `Role` inherits an intermediary class which, for the sake of simplicity, has not been documented. Therefore, besides the `Concept` methods, Role inherits the following methods from the `Type` class. - [label();](?tab=python#retrieve-label) - [type.label(Label.of(label));](?tab=python#rename-label) - [sup();](?tab=python#retrieve-direct-supertype) - [sup(Type type);](?tab=python#change-direct-supertype) - [sups();](?tab=python#retrieve-all-supertypes) - [subs();](?tab=python#retrieve-all-subtypes)

Retrieve relations

role.relations()

Retrieves the Relation instances that this role is related to.

Returns

Iterator of Relation objects

Retrieve roleplayers

role.players()

Retrieves the Types whose instances play this role.

Returns

Iterator of Type objects

[tab:end]