- Organization
- Obtaining instances
- Inheritance
- Organization.addDataset(name: string, metadata?: object)
- Organization.addMember(user: User, role?: Role)
- Organization.removeMember(user: User)
- Organization.addQuery(name: string, metadata: object)
- Organization.ensureStory(name: string, metadata: object)
- Organization.addStory(name: string, metadata?: object)
- Organization.delete()
- Organization.ensureDataset(name: string, metadata?: object)
- Organization.getDataset(name: string)
- Organization.getDatasets()
- Organization.getMembers()
- Organization.getPinnedItems()
- Organization.removeMember(user: User)
- Organization.setAvatar(file: string)
- Organization.update(metadata: object)
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
of either member or owner.
Arguments¶
-
The
user
argument has to be a user object of the user which should be added to the organization. -
The
role
argument can be either'member'
or'owner'
. If this argument is not specified, then'member'
is used as the default.
'member'
- A regular member that is allowed to read and write the datasets that are published under the organization.
'owner'
- An owner of the organization. Owners have all the rights of regular users, plus 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.
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 (
OrgRole
): either'owner'
for owners of the organization, or'member'
for regular members. The difference between owners and regular members is that owners can perform user management for the organization (add/remove/change memberships). 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)
.