Organization

Instances of class Organization denote organizations in TriplyDB.

Obtaining instances

Organizations are obtained with method App.getOrganization(name: string):

const organization = await triply.getOrganization('Triply')

Alternatively, organizations are obtained by first obtaining an account (App.getAccount(name?: string)) and then casting it to an organization (Account.asOrganization()):

const account = await triply.getAccount('Triply')
const organization = account.asOrganization()

Inheritance

Organization is a subclass of Account, from which it inherits most of its methods.

Organization.addDataset(name: string, metadata?: object)

Adds a new TriplyDB dataset with the given name to the current organization.

Inherited from Account.addDataset(name: string, metadata?: object).

Organization.addMember(user: User, role?: Role)

Adds a member to the given Organization, with the given role.

Arguments

  • The user argument has to be a user object of the user which should be added to the organization.

  • The role argument specifies the role to assign to the new member. If this argument is not specified, then 'member' is used as the default. The following system roles are always available:

'member' (default)
Can manage resources (datasets, queries, stories) but cannot manage organization members or delete the organization.
'owner'
Full access to all account resources and settings, including the ability to add/remove users to/from the organization, the ability to change the roles of existing users, and the ability to delete the organization.

In addition to the system roles, administrators can configure custom roles with specific permissions. Any custom role name that has been configured on the TriplyDB instance can be passed as the role argument. See the Roles documentation for more information.

Examples

user The following snippet adds user John Doe to the Triply organization as a regular member.

const organization = await triply.getOrganization('Triply')
const johnDoe = await app.getUser('john-doe')
await organization.addMember(johnDoe)

Organization.removeMember(user: User)

Removes a member from the given Organization.

Organization.addQuery(name: string, metadata: object)

Adds a new TriplyDB query to the current organization.

Inherited from Account.addQuery(name: string, metadata: object).

Organization.ensureStory(name: string, metadata: object)

Ensures the existence of a story with the given name and with the specified metadata.

Inherited from Account.ensureStory(name: string, metadata: object).

Organization.addStory(name: string, metadata?: object)

Adds a new TriplyDB story with the given name to the current organization.

Inherited from Account.addStory(name: string, metadata?: object).

Organization.delete()

Deletes this account. This also deletes all datasets, stories and queries that belong to this organization.

Examples

The following code example deletes the specified organization:

const organization = await triply.getOrganization('Neo4j')
await organization.delete()

Organization.ensureDataset(name: string, metadata?: object)

Ensures the existence of a dataset with the given name and with the specified metadata.

Inherited from Account.ensureDataset(name: string, metadata?: object).

Organization.getDataset(name: string)

Returns the dataset with the given name that is published by this organization.

Inherited from Account.getDataset(name: string).

Organization.getDatasets()

Returns an async iterator over the accessible datasets that belong to this organization.

Inherited from Account.getDatasets().

Organization.getMembers()

Returns the list of memberships for the given organization.

Return type

A membership contains the following components:

role
The role of the membership. This is one of the system roles ('owner' or 'member') or a custom role name configured by an administrator. See the Roles documentation for more information.
user
An instance of class User.
createdAt
A date/time string.
updatedAt
A date/time string.

Examples

const org = await triply.getOrganization('acme')
for (const membership of await org.getMembers()) {
  console.log(user)
}

See also

Memberships of organization are TriplyDB users.

Organization.getPinnedItems()

Returns the list of datasets, stories and queries that are pinned for the current organization.

Inherited from Account.getPinnedItems().

Organization.removeMember(user: User)

Removes the specified user from this organization.

Arguments

The user argument has to be a User object of a user.

Existence considerations

The user must be a current member of the organization for this method to succeed. If the user is not a current member of the organization, an error is thrown.

Examples

  • The following snippet removes John Doe from the Triply organization, using a string argument:
const organization = await triply.getOrganization('Triply')
const johnDoe = await app.getUser('john-doe')
await organization.removeMember(johnDoe)
  • The following snippet removes John Doe from the Triply organization, using a User object:
const organization = await triply.getOrganization('Triply')
const user = await triply.getUser('john-doe')
await organization.removeMember(user)

Organization.setAvatar(file: string)

Sets a new image that characterized this organization.

Inherited from Account.setAvatar(file: string).

Organization.update(metadata: object)

Updates the metadata for this account.

Inherited from Account.update(metadata: object).