Skip to content

Function: createDataResource

createDataResource(uri, overwrite, options?): Promise\<ContainerCreateAndOverwriteResult>

Creates a data resource (RDF resource) at the provided URI. This resource could also be a container.

Parameters

Name Type Description
uri ContainerUri The URI of the resource
overwrite true If true, the request will overwrite any previous resource at this URI.
options? DatasetRequestOptions Options to provide a fetch function and a local dataset to update.

Returns

Promise\<ContainerCreateAndOverwriteResult>

One of many create results depending on the input

Example

createDataResource can be used to create containers.

import { createDataResource } from "@ldo/solid";
import { fetch } from "@inrupt/solid-client-autn-js";

const result = await createDataResource(
  "https://example.com/container/",
  true,
  { fetch },
);
if (!result.isError) {
  // Do something
}

Example

createDataResource can also create a blank data resource at the provided URI.

import { createDataResource } from "@ldo/solid";
import { fetch } from "@inrupt/solid-client-autn-js";

const result = await createDataResource(
  "https://example.com/container/someResource.ttl",
  true,
  { fetch },
);
if (!result.isError) {
  // Do something
}

Example

Any local RDFJS dataset passed to the options field will be updated with any new RDF data from the create process.

import { createDataResource } from "@ldo/solid";
import { createDataset } from "@ldo/dataset"
import { fetch } from "@inrupt/solid-client-autn-js";

const localDataset = createDataset();
const result = await createDataResource(
  "https://example.com/container/someResource.ttl",
  true,
  { fetch, dataset: localDataset },
);
if (!result.isError) {
  // Do something
}

Defined in

packages/solid/src/requester/requests/createDataResource.ts:135

createDataResource(uri, overwrite, options?): Promise\<LeafCreateAndOverwriteResult>

Parameters

Name Type
uri LeafUri
overwrite true
options? DatasetRequestOptions

Returns

Promise\<LeafCreateAndOverwriteResult>

Defined in

packages/solid/src/requester/requests/createDataResource.ts:140

createDataResource(uri, overwrite?, options?): Promise\<ContainerCreateIfAbsentResult>

Parameters

Name Type
uri ContainerUri
overwrite? false
options? DatasetRequestOptions

Returns

Promise\<ContainerCreateIfAbsentResult>

Defined in

packages/solid/src/requester/requests/createDataResource.ts:145

createDataResource(uri, overwrite?, options?): Promise\<LeafCreateIfAbsentResult>

Parameters

Name Type
uri LeafUri
overwrite? false
options? DatasetRequestOptions

Returns

Promise\<LeafCreateIfAbsentResult>

Defined in

packages/solid/src/requester/requests/createDataResource.ts:150

createDataResource(uri, overwrite?, options?): Promise\<ContainerCreateIfAbsentResult | ContainerCreateAndOverwriteResult>

Parameters

Name Type
uri ContainerUri
overwrite? boolean
options? DatasetRequestOptions

Returns

Promise\<ContainerCreateIfAbsentResult | ContainerCreateAndOverwriteResult>

Defined in

packages/solid/src/requester/requests/createDataResource.ts:155

createDataResource(uri, overwrite?, options?): Promise\<LeafCreateIfAbsentResult | LeafCreateAndOverwriteResult>

Parameters

Name Type
uri LeafUri
overwrite? boolean
options? DatasetRequestOptions

Returns

Promise\<LeafCreateIfAbsentResult | LeafCreateAndOverwriteResult>

Defined in

packages/solid/src/requester/requests/createDataResource.ts:160

createDataResource(uri, overwrite, options?): Promise\<ContainerCreateAndOverwriteResult | LeafCreateAndOverwriteResult>

Parameters

Name Type
uri string
overwrite true
options? DatasetRequestOptions

Returns

Promise\<ContainerCreateAndOverwriteResult | LeafCreateAndOverwriteResult>

Defined in

packages/solid/src/requester/requests/createDataResource.ts:165

createDataResource(uri, overwrite?, options?): Promise\<LeafCreateIfAbsentResult | LeafCreateIfAbsentResult>

Parameters

Name Type
uri string
overwrite? false
options? DatasetRequestOptions

Returns

Promise\<LeafCreateIfAbsentResult | LeafCreateIfAbsentResult>

Defined in

packages/solid/src/requester/requests/createDataResource.ts:170

createDataResource(uri, overwrite?, options?): Promise\<ContainerCreateAndOverwriteResult | LeafCreateAndOverwriteResult | ContainerCreateIfAbsentResult | LeafCreateIfAbsentResult>

Parameters

Name Type
uri string
overwrite? boolean
options? DatasetRequestOptions

Returns

Promise\<ContainerCreateAndOverwriteResult | LeafCreateAndOverwriteResult | ContainerCreateIfAbsentResult | LeafCreateIfAbsentResult>

Defined in

packages/solid/src/requester/requests/createDataResource.ts:175