@triply/triplydb
    Preparing search index...

    Class User

    A TriplyDB user account.

    Obtain one with App.getUser for a specific user, or App.getAccount when the account may be either a user or a Group. Users are never constructed directly, and cannot be created or deleted through this library.

    Everything a user shares with a group — datasets, queries, stories — is described on Account.

    import App from "@triply/triplydb";

    const app = App.get({ token: process.env.TOKEN });
    const me = await app.getUser();
    const user = await app.getUser("my-user");
    const dataset = await user.getDataset("my-dataset");

    Hierarchy

    • SharedAccountMembers
      • User

    Implements

    Index
    accountType: "User"

    Always "User", so an Account can be narrowed without a request.

    slug: string

    The user's account name, which is part of every URL under it.

    • Creates a new, empty dataset owned by this account.

      Parameters

      • name: string

        Name for the new dataset, which becomes part of its URL.

      • Optionalds: AddDatasetOptions

        Metadata to create it with. accessLevel defaults to the instance's own default.

      Returns Promise<Dataset>

      A new dataset has no graphs; load data into it with Dataset.importFromFiles, Dataset.importFromUrls or Dataset.importFromDataset.

      If the name is already taken — it becomes part of the dataset's URL, so an account cannot have two. Use ensureDataset when you want the existing dataset instead of an error.

    • Creates a new saved query owned by this account.

      Parameters

      • name: string

        Name for the new query, which becomes part of its URL.

      • opts: AddQueryOptions

        The query text plus the dataset and service type to run it against; both are required, because a saved query is stored together with what it queries.

      Returns Promise<Query>

      If the name is already taken. Use getQuery to fetch the existing one.

    • Creates a new story owned by this account.

      Parameters

      • name: string

        Name for the new story, which becomes part of its URL.

      • Optionalargs: NewStory | NewStory_deprecated

        Initial content and access level. A story created without content is empty and can be filled in later.

      Returns Promise<Story>

      If the name is already taken. Use ensureStory when you want the existing one.

    • This account as a Group.

      Returns Promise<Group>

      For narrowing an Account whose kind you have established. A user cannot become a group.

      If this account is a User.

    • This account as a User.

      Returns Promise<User>

      For narrowing an Account whose kind you have established.

      If this account is a Group.

    • Creates a group owned by this user.

      Parameters

      • accountName: string

        Name for the group, which becomes part of its URL.

      • Optionalinfo: NewGroup

        Metadata to create it with, including its access level.

      Returns Promise<Group>

      If the name is already taken by any account. Use User.ensureGroup when you want the existing group.

      IncompatibleError against an instance older than 26.4.300, or older than 26.8.100 when info.accessLevel is set — a 26.7.x server drops the key and would create a public group instead.

    • Parameters

      • accountName: string
      • Optionalinfo: NewGroup

      Returns Promise<Group>

      Use createGroup()

    • The dataset with this name, created first if this account does not have one yet.

      Parameters

      • name: string

        Name of the dataset to get or create.

      • OptionalnewDs: AddDatasetOptions

        Metadata to create it with, used only when it does not exist yet.

      Returns Promise<Dataset>

      The idempotent form of addDataset, for code that runs more than once.

      Only the absence of the dataset is reconciled: when it already exists, newDs is ignored rather than applied, so this never edits an existing dataset's metadata.

      If the dataset exists and newDs.accessLevel disagrees with the access level it already has — rather than silently leaving it as it was.

    • The group with this name, created first if it does not exist yet.

      Parameters

      • name: string
      • OptionalnewGroup: NewGroup

      Returns Promise<Group>

      The idempotent form of User.createGroup. As elsewhere, newGroup applies only when the group is created, so this never edits an existing group.

      If the group exists and newGroup.accessLevel disagrees with the access level it already has — rather than silently leaving it as it was.

      IncompatibleError against an instance older than 26.4.300, or older than 26.8.100 when newGroup.accessLevel is set.

    • Parameters

      Returns Promise<Group>

      Use ensureGroup()

    • The story with this name, created first if this account does not have one yet.

      Parameters

      Returns Promise<Story>

      The idempotent form of addStory. As with ensureDataset, newStory applies only when the story does not exist yet, so this never edits an existing story.

      If the story exists and newStory.accessLevel disagrees with the access level it already has — rather than silently leaving it as it was.

    • The dataset with this name, owned by this account.

      Parameters

      • name: string

        The dataset's name, as it appears in its URL.

      Returns Promise<Dataset>

      If this account has no dataset with that name. Use hasDataset to test first, or ensureDataset to create it when missing.

    • One group this user belongs to.

      Parameters

      • name: string

      Returns Promise<Group>

      If this user is not a member of a group with that name. Use App.getGroup to reach a group without going through its membership.

      IncompatibleError against an instance older than 26.4.300.

    • The groups this user belongs to.

      Returns Promise<Group[]>

      IncompatibleError against an instance older than 26.4.300.

    • This user's metadata: their name, display name and profile fields.

      Parameters

      • refresh: boolean = false

      Returns Promise<UserInfo>

      Cached after the first call. Pass true to refetch.

    • Parameters

      • name: string

      Returns Promise<Group>

      Use getGroup()

    • Returns Promise<Group[]>

      Use getGroups()

    • The datasets, stories and queries pinned to this account's profile, in the order they appear.

      Returns Promise<(Dataset | Query | Story)[]>

      A single list of mixed kinds; narrow with instanceof when you need to treat them differently.

    • The saved query with this name, owned by this account.

      Parameters

      • name: string

        The query's name, as it appears in its URL.

      Returns Promise<Query>

      If this account has no query with that name. Use hasQuery to test first.

    • The story with this name, owned by this account.

      Parameters

      • name: string

        The story's name, as it appears in its URL.

      Returns Promise<Story>

      If this account has no story with that name. Use hasStory to test first.

    • Whether this account has a dataset with this name, without throwing when it does not.

      Parameters

      • name: string

      Returns Promise<boolean>

    • Whether this account has a saved query with this name, without throwing when it does not.

      Parameters

      • name: string

      Returns Promise<boolean>

    • Whether this account has a story with this name, without throwing when it does not.

      Parameters

      • name: string

      Returns Promise<boolean>

    • Copies a dataset from another instance into this account.

      Parameters

      Returns Promise<Dataset>

      For moving content between deployments. Destructive: opts.overwrite must be true, and a dataset of the same name in this account is replaced rather than merged into.

      If the source is on the same instance as this account — importing is only supported between different instances. Use Dataset.importFromDataset to copy within one.

    • Sets which datasets, stories and queries are pinned to this account's profile.

      Parameters

      Returns Promise<User>

      Replaces the pinned list rather than adding to it, and the array's order becomes the display order. To add one, read AccountBase.getPinnedItems first and pass the result back with your addition; passing an empty array unpins everything.

    • Runs saved queries as one batch job and writes their results into a dataset.

      Parameters

      • opts: RunPipelineOpts

        The queries to run and the dataset to write to. source is only needed when the queries do not all target the same dataset.

      Returns Promise<Pipeline>

      The way to materialise query results at scale, rather than paging through them in process. The returned Pipeline has started but not finished — wait for it with Pipeline.waitForPipelineToFinish, or follow it through opts.onProgress.

      If opts.queries is empty; or, when opts.source is omitted, if the queries reference no dataset at all or reference more than one — in both cases pass source explicitly.

    • Replaces this account's profile image.

      Parameters

      • pathOrBuffer: string | Buffer<ArrayBufferLike>

        Path to an image file, or its contents.

      Returns Promise<void>

    • Changes this account's profile fields.

      Parameters

      Returns Promise<User>

      Only the fields you pass are changed; the rest are left alone. Pinned items are not settable here — use AccountBase.pinItems.

      A Group widens this to accept accessLevel as well, since only a group has one.