module:store/Resource

module:store/Resource

This is the base class for resources contained by entries, do not use directly, instead use a subclass.

Constructor

new (require("store/Resource"))(entryURI, resourceURI, entryStore)

Source:
See:
  • subclass Context
  • subclass List
  • subclass Graph
  • subclass String
  • subclass File
  • subclass User
  • subclass Group
Parameters:
Name Type Description
entryURI string

URI to an entry where this resource is contained.

resourceURI string

URI to the resource.

entryStore EntryStore

the API's repository instance.

Methods

getEntry() → {Promise.<Entry>|Entry}

Source:

Retrieves the entry that contains this resource. Asking for the entry directly (direct=true, rather than getting it asynchronously via a promise) should work for all resources except context resources.

Advanced explanation: Context resources are often created opportunistically by the API without also loading the context entry along with it, e.g. when loading entries during a search operation. The reason why the context entries are not loaded along with the context resource is that such an approach, depending on the use-case, may lead to dramatic increases in the amount of requests to the repository.

Returns:

if direct=true an Entry is returned (or undefined if not in cache, only happens sometimes for Contexts) otherwise a promise is returned that on success provides the entry for this resource.

Type
Promise.<Entry> | Entry

getEntryStore() → {EntryStore}

Source:

Retrieves the API's repository instance

Returns:
Type
EntryStore

getEntryURI() → {string}

Source:

The URI to the entry containing this resource.

Returns:
Type
string

getId() → {string}

Source:

The id for the entry containing this resource.

Returns:
Type
string

getResourceURI() → {string}

Source:

The resources own URI.

Returns:
Type
string