API Docs for: 5.4.0-alpha.75+3cf8e39f
Show:

Document Class

A Document is a class that wraps the response content from a request to the API returned by Cache.put or Cache.peek, converting resource-identifiers into record instances.

It is not directly instantiated by the user, and its properties should not be directly modified. Whether individual properties are mutable or not is determined by the record instance itself.

Item Index

Methods

fetch

(
  • options
)
public

Fetches the related link for this document, returning a promise that resolves with the document when the request completes. If no related link is present, will fallback to the self link if present

Parameters:

  • options Object

Returns:

Promise

first

(
  • options
)
public

Fetches the first link for this document, returning a promise that resolves with the new document when the request completes, or null if there is no first link.

Parameters:

  • options Object

Returns:

Promise<Document | null>

last

(
  • options
)
public

Fetches the last link for this document, returning a promise that resolves with the new document when the request completes, or null if there is no last link.

Parameters:

  • options Object

Returns:

Promise<Document | null>

next

(
  • options
)
public

Fetches the next link for this document, returning a promise that resolves with the new document when the request completes, or null if there is no next link.

Parameters:

  • options Object

Returns:

Promise<Document | null>

prev

(
  • options
)
public

Fetches the prev link for this document, returning a promise that resolves with the new document when the request completes, or null if there is no prev link.

Parameters:

  • options Object

Returns:

Promise<Document | null>

toJSON

() public

Implemented for JSON.stringify support.

Returns the JSON representation of the document wrapper.

This is a shallow serialization, it does not deeply serialize the document's contents, leaving that to the individual record instances to determine how to do, if at all.

Returns:

Properties

data

Object | Array | Null | Undefined - a data object public

The primary data for this document, if any.

If this document has no primary data (e.g. because it is an error document) this property will be undefined.

For collections this will be an array of record instances, for single resource requests it will be a single record instance or null.

errors

Object | Undefined - an errors object public

The errors returned by the API for this request, if any

identifier

StableDocumentIdentifier | Null public

The identifier associated with this document, if any

meta

Object | Undefined - a meta object public

The meta object for this document, if any