Skip to content

Class: ResourceLinkQuery\<Type, QueryInput, Plugins>

Represents a query over multiple datasources and constituting muliple resources.

Example

import { ProfileShapeType } from "./.ldo/Profile.shapeType.ts";

// Create a link query
const linkQuery = ldoDataset
  .usingType(ProfileShapeType)
  .startLinkQuery(
    "http://example.com/profile/card",
    "http://example.com/profile/card#me",
    {
      name: true,
        knows: {
          name: true,
        },
      },
    }
  );
// Susbscribe to this link query, automaticically updating the dataset when
// something from the link query is changed.
await linkQuery.subscribe();

Type parameters

Name Type
Type extends LdoBase
QueryInput extends LQInput\<Type>
Plugins extends ConnectedPlugin[]

Implements

Constructors

constructor

new ResourceLinkQuery\<Type, QueryInput, Plugins>(parentDataset, shapeType, ldoBuilder, startingResource, startingSubject, linkQueryInput): ResourceLinkQuery\<Type, QueryInput, Plugins>

Type parameters

Name Type
Type extends LdoBase
QueryInput extends Partial\<{ [key in string | number | symbol]: LQInputFlattenSet\<Type[key]> }>
Plugins extends ConnectedPlugin\<any, any, any, any, any>[]

Parameters

Name Type Description
parentDataset IConnectedLdoDataset\<Plugins> The dataset for which this link query is a part
shapeType ShapeType\<Type> A ShapeType for the link query to follow
ldoBuilder IConnectedLdoBuilder\<Type, Plugins> An LdoBuilder associated with the dataset
startingResource Plugins[number]["types"]["resource"] The resource to explore first in the link query
startingSubject string | SubjectNode The starting point of the link query
linkQueryInput QueryInput A definition of the link query

Returns

ResourceLinkQuery\<Type, QueryInput, Plugins>

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:73

Properties

activeResourceSubscriptions

Protected activeResourceSubscriptions: Record\<string, string> = {}

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:53


curOnDataChanged

Protected curOnDataChanged: undefined | nodeEventListener\<Quad>

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:57


ldoBuilder

Protected ldoBuilder: IConnectedLdoBuilder\<Type, Plugins>

An LdoBuilder associated with the dataset

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:76


linkQueryInput

Protected linkQueryInput: QueryInput

A definition of the link query

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:79


parentDataset

Protected parentDataset: IConnectedLdoDataset\<Plugins>

The dataset for which this link query is a part

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:74


previousTransactionId

Protected previousTransactionId: string = "INIT"

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:50


resourcesWithSubscriptionInProgress

Protected resourcesWithSubscriptionInProgress: Record\<string, undefined | Promise\<void>> = {}

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:59


shapeType

Protected shapeType: ShapeType\<Type>

A ShapeType for the link query to follow

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:75


startingResource

Protected startingResource: Plugins[number]["types"]["resource"]

The resource to explore first in the link query

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:77


startingSubject

Protected startingSubject: string | SubjectNode

The starting point of the link query

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:78


thisUnsubscribeIds

Protected thisUnsubscribeIds: Set\<string>

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:55

Methods

fromSubject

fromSubject(): ExpandDeep\<LQReturn\<Type, QueryInput>>

Returns

ExpandDeep\<LQReturn\<Type, QueryInput>>

Implementation of

ILinkQuery.fromSubject

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:276


fullUnsubscribe

fullUnsubscribe(): Promise\<void>

Returns

Promise\<void>

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:252


getSubscribedResources

getSubscribedResources(): Plugins[number]["types"]["resource"][]

Returns

Plugins[number]["types"]["resource"][]

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:282


run

run(options?): Promise\<ExpandDeep\<LQReturn\<Type, QueryInput>>>

Runs this link query, returning the result

Parameters

Name Type Description
options? Object Options for how to run the link query
options.reload? boolean -

Returns

Promise\<ExpandDeep\<LQReturn\<Type, QueryInput>>>

A subset of the ShapeType as defined by the LinkQuery

Example

import { ProfileShapeType } from "./.ldo/Profile.shapeType.ts";

// Create a link query
const linkQuery = ldoDataset
  .usingType(ProfileShapeType)
  .startLinkQuery(
    "http://example.com/profile/card",
    "http://example.com/profile/card#me",
    {
      name: true,
        knows: {
          name: true,
        },
      },
    }
  );
// Susbscribe to this link query, automaticically updating the dataset when
// something from the link query is changed.
const result = await linkQuery.read();
console.log(result.name);
result.knows.forEach((person) => console.log(person.name));
// The following will type-error. Despite "phone" existing on a Profile,
// it was not covered by the link query.
console.log(result.phone);

Implementation of

ILinkQuery.run

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:115


subscribe

subscribe(): Promise\<string>

Subscribes to the data defined by the link query, updating the dataset if any changes are made.

Returns

Promise\<string>

An unsubscribeId

Example

import { ProfileShapeType } from "./.ldo/Profile.shapeType.ts";

// Create a link query
const linkQuery = ldoDataset
  .usingType(ProfileShapeType)
  .startLinkQuery(
    "http://example.com/profile/card",
    "http://example.com/profile/card#me",
    {
      name: true,
        knows: {
          name: true,
        },
      },
    }
  );
// Susbscribe to this link query, automaticically updating the dataset when
// something from the link query is changed.
const unsubscribeId = await linkQuery.subscribe();

// Now, let's imagine the following triple was added to
"http://example.com/profile/card":
<http://example.com/profile/card#me> <http://xmlns.com/foaf/0.1/knows> <http://example2.com/profile/card#me>
Because you're subscribed, the dataset will automatically be updated.

// End subscription
linkQuery.unsubscribe(unsubscribeId);

Implementation of

ILinkQuery.subscribe

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:165


unsubscribe

unsubscribe(unsubscribeId): Promise\<void>

Parameters

Name Type
unsubscribeId string

Returns

Promise\<void>

Implementation of

ILinkQuery.unsubscribe

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:264


unsubscribeAll

unsubscribeAll(): Promise\<void>

Returns

Promise\<void>

Implementation of

ILinkQuery.unsubscribeAll

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:271


unsubscribeFromResource

unsubscribeFromResource(uri): Promise\<void>

Parameters

Name Type
uri any

Returns

Promise\<void>

Defined in

packages/connected/src/linkTraversal/ResourceLinkQuery.ts:245