@inrupt/solid-client / resource/solidDataset

# Module: resource/solidDataset¶

## Functions¶

### changeLogAsMarkdown¶

changeLogAsMarkdown(solidDataset): string

Gets a human-readable representation of the local changes to a Resource to aid debugging.

Note that changes to the exact format of the return value are not considered a breaking change; it is intended to aid in debugging, not as a serialisation method that can be reliably parsed.

since 0.3.0

#### Parameters¶

Name

Type

Description

solidDataset

SolidDataset & WithChangeLog

The Resource of which to get a human-readable representation of the changes applied to it locally.

#### Returns¶

string

#### Defined in¶

src/resource/solidDataset.ts:853

### createContainerAt¶

createContainerAt(url, options?): Promise<SolidDataset & WithServerResourceInfo>

Create an empty Container at the given URL.

Throws an error if creating the Container failed, e.g. because the current user does not have permissions to, or because the Container already exists.

Note that a Solid server will automatically create the necessary Containers when storing a Resource; i.e. there is no need to call this function if it is immediately followed by saveSolidDatasetAt or overwriteFile.

since 0.2.0

#### Parameters¶

Name

Type

Description

url

URL of the empty Container that is to be created.

options

Partial<typeof internal\_defaultFetchOptions>

Optional parameter options.fetch: An alternative fetch function to make the HTTP request, compatible with the browser-native fetch API.

#### Returns¶

Promise<SolidDataset & WithServerResourceInfo>

#### Defined in¶

src/resource/solidDataset.ts:434

### createContainerInContainer¶

createContainerInContainer(containerUrl, options?): Promise<SolidDataset & WithResourceInfo>

Create an empty Container inside the Container at the given URL.

Throws an error if creating the Container failed, e.g. because the current user does not have permissions to.

The Container in which to create the new Container should itself already exist.

since 0.2.0

#### Parameters¶

Name

Type

Description

containerUrl

URL of the Container in which the empty Container is to be created.

options

SaveInContainerOptions

Optional parameter options.fetch: An alternative fetch function to make the HTTP request, compatible with the browser-native fetch API.

#### Returns¶

Promise<SolidDataset & WithResourceInfo>

#### Defined in¶

src/resource/solidDataset.ts:703

### createSolidDataset¶

createSolidDataset(): SolidDataset

Initialise a new SolidDataset in memory.

#### Returns¶

SolidDataset

An empty SolidDataset.

#### Defined in¶

src/resource/solidDataset.ts:74

### deleteContainer¶

deleteContainer(container, options?): Promise<void>

Deletes the Container at a given URL.

since 0.6.0

#### Parameters¶

Name

Type

container

options

Partial<typeof internal\_defaultFetchOptions>

#### Returns¶

Promise<void>

#### Defined in¶

src/resource/solidDataset.ts:761

### deleteSolidDataset¶

deleteSolidDataset(solidDataset, options?): Promise<void>

Deletes the SolidDataset at a given URL.

since 0.6.0

#### Parameters¶

Name

Type

solidDataset

options

Partial<typeof internal\_defaultFetchOptions>

#### Returns¶

Promise<void>

#### Defined in¶

src/resource/solidDataset.ts:397

### getContainedResourceUrlAll¶

getContainedResourceUrlAll(solidDataset): UrlString[]

Given a SolidDataset representing a Container (see isContainer), fetch the URLs of all contained resources. If the solidDataset given is not a container, or is missing resourceInfo, throw an error.

since 1.3.0

#### Parameters¶

Name

Type

Description

solidDataset

The container from which to fetch all contained Resource URLs.

#### Returns¶

A list of URLs, each of which points to a contained Resource of the given SolidDataset.

#### Defined in¶

src/resource/solidDataset.ts:800

### getSolidDataset¶

getSolidDataset(url, options?): Promise<SolidDataset & WithServerResourceInfo>

Fetch a SolidDataset from the given URL. Currently requires the SolidDataset to be available as Turtle.

#### Parameters¶

Name

Type

Description

url

URL to fetch a SolidDataset from.

options

Partial<typeof internal\_defaultFetchOptions & ParseOptions>

Optional parameter options.fetch: An alternative fetch function to make the HTTP request, compatible with the browser-native fetch API.

#### Returns¶

Promise<SolidDataset & WithServerResourceInfo>

Promise resolving to a SolidDataset containing the data at the given Resource, or rejecting if fetching it failed.

#### Defined in¶

src/resource/solidDataset.ts:219

### saveSolidDatasetAt¶

saveSolidDatasetAt<Dataset>(url, solidDataset, options?): Promise<Dataset & WithServerResourceInfo & WithChangeLog>

Given a SolidDataset, store it in a Solid Pod (overwriting the existing data at the given URL).

A SolidDataset keeps track of the data changes compared to the data in the Pod; i.e., the changelog tracks both the old value and new values of the property being modified. This function applies the changes to the current SolidDataset. If the old value specified in the changelog does not correspond to the value currently in the Pod, this function will throw an error. The SolidDataset returned by this function will contain the data sent to the Pod, and a ChangeLog up-to-date with the saved data. Note that if the data on the server was modified in between the first fetch and saving it, the updated data will not be reflected in the returned SolidDataset. To make sure you have the latest data, call getSolidDataset again after saving the data.

The Solid server will create any intermediary Containers that do not exist yet, so they do not need to be created in advance. For example, if the target URL is https://example.pod/container/resource and https://example.pod/container/ does not exist yet, it will exist after this function resolves successfully.

#### Type parameters¶

Name

Type

Dataset

Dataset: Readonly<Object>

#### Parameters¶

Name

Type

Description

url

URL to save solidDataset to.

solidDataset

Dataset

The SolidDataset to save.

options

Partial<typeof internal\_defaultFetchOptions>

Optional parameter options.fetch: An alternative fetch function to make the HTTP request, compatible with the browser-native fetch API.

#### Returns¶

Promise<Dataset & WithServerResourceInfo & WithChangeLog>

A Promise resolving to a SolidDataset containing the stored data, or rejecting if saving it failed.

#### Defined in¶

src/resource/solidDataset.ts:340

### saveSolidDatasetInContainer¶

saveSolidDatasetInContainer(containerUrl, solidDataset, options?): Promise<SolidDataset & WithResourceInfo>

Given a SolidDataset, store it in a Solid Pod in a new Resource inside a Container.

The Container at the given URL should already exist; if it does not, you can initialise it first using createContainerAt, or directly save the SolidDataset at the desired location using saveSolidDatasetAt.

#### Parameters¶

Name

Type

Description

containerUrl

URL of the Container in which to create a new Resource.

solidDataset

SolidDataset

The SolidDataset to save to a new Resource in the given Container.

options

SaveInContainerOptions

Optional parameter options.fetch: An alternative fetch function to make the HTTP request, compatible with the browser-native fetch API.

#### Returns¶

Promise<SolidDataset & WithResourceInfo>

A Promise resolving to a SolidDataset containing the saved data. The Promise rejects if the save failed.

#### Defined in¶

src/resource/solidDataset.ts:617

### solidDatasetAsMarkdown¶

solidDatasetAsMarkdown(solidDataset): string

Gets a human-readable representation of the given SolidDataset to aid debugging.

Note that changes to the exact format of the return value are not considered a breaking change; it is intended to aid in debugging, not as a serialisation method that can be reliably parsed.

since 0.3.0

#### Parameters¶

Name

Type

Description

solidDataset

SolidDataset

The SolidDataset to get a human-readable representation of.

#### Returns¶

string

#### Defined in¶

src/resource/solidDataset.ts:819