@AppKu/StashKu

@AppKu/StashKu

v1.0.46

Class

BaseEngine

This abstract base class defines the structure of a StashKu-compatible engine. All StashKu engines must extend this class.

The implementing engine should implement it's own schema, get, post, put, patch, and delete functions when supported. If the RESTful function is not supported it should not be overriden so that this base class can throw a 501 "Not supported" error.

Constructor

abstract

new BaseEngine(name)

Instantiates a new BaseEngine.

Parameters

  • name String

    The name of this storage engine.

Source

Members

Methods

abstract

configure(config, loggeropt)

Sets the storage engine configuration property. This function is called automatically by StashKu when the engine is initialized or when the configuration source has been changed.

Parameters

  • config *

    The configuration object for the storage engine.

  • logger Logger <optional>

    Optional Logger instance to set on the engine. This is usually assigned to the same instance as the StashKu parent.

Source

asyncabstract

delete(request) → {Promise.<Response>}

Run a DELETE request and deletes all objects in storage matching the DELETE request criteria.

Parameters

  • request DeleteRequest

    The DELETE request to send to the storage engine.

Returns

  • Promise.<Response>

    Returns the data objects from storage that were deleted with the request criteria.

Throws

  1. A 501 REST error if not overriden and supported by the storage engine.

  2. A 400 REST error if the request is missing or not a DeleteRequest.

  3. A 400 REST error if the request missing required metadata.

  4. A 400 REST error if the request metadata is missing a required "from" value.

  5. A 400 REST error if the request metadata is missing "where" conditions to match objects in storage and is not enabled to affect all objects.

Source

asyncabstract

destroy()

Standardized method to clean up resources within a storage engine. This is called from the StashKu instance when an engine is replaced or removed, or the instance is destroyed.

Source

asyncabstract

get(request) → {Promise.<Response>}

Run a GET request and returns objects from storage that match the GET request criteria.

Parameters

  • request GetRequest

    The GET request to send to the storage engine.

Returns

  • Promise.<Response>

    Returns the data objects from storage matching request criteria.

Throws

  1. A 501 REST error if not overriden and supported by the storage engine.

  2. A 400 REST error if the request is missing or not a GetRequest.

  3. A 400 REST error if the request missing required metadata.

  4. A 400 REST error if the request metadata is missing a required "from" value.

Source

asyncabstract

options(request) → {Promise.<Response>}

Run an OPTIONS request which returns a dynamically constructed model type which defines how StashKu can interact with the target (from) resource.

Parameters

  • request OptionsRequest

    The OPTIONS request to send to the storage engine.

Returns

  • Promise.<Response>

    Returns a response with a single data object- the dynamically created model configuration.

Throws

  1. A 501 REST error if not overriden and supported by the storage engine.

  2. A 400 REST error if the request is missing or not a OptionsRequest.

  3. A 400 REST error if the request missing required metadata.

  4. A 400 REST error if the request metadata is missing a required "from" value.

  5. A 400 REST error if the request metadata is missing "where" conditions to match objects in storage and is not enabled to affect all objects.

Source

asyncabstract

patch(request) → {Promise.<Response>}

Run a PATCH request and updates all objects in storage matching the PATCH request criteria. A count of the number of objects affected is returned.

Parameters

  • request PatchRequest

    The PATCH request to send to the storage engine.

Returns

  • Promise.<Response>

    Returns a response with the total number of the objects affected in storage. No data objects are typically returned with this request.

Throws

  1. A 501 REST error if not overriden and supported by the storage engine.

  2. A 400 REST error if the request is missing or not a PatchRequest.

  3. A 400 REST error if the request missing required metadata.

  4. A 400 REST error if the request metadata is missing a required "to" value.

  5. A 400 REST error if the request metadata is missing a "template" object.

  6. A 400 REST error if the request metadata is missing "where" conditions to match objects in storage and is not enabled to affect all objects.

Source

asyncabstract

post(request) → {Promise.<Response>}

Run a POST request and creates (then returns) objects in storage.

Parameters

  • request PostRequest

    The POST request to send to the storage engine.

Returns

  • Promise.<Response>

    Returns the data objects from storage that were created with the request criteria.

Throws

  1. A 501 REST error if not overriden and supported by the storage engine.

  2. A 400 REST error if the request is missing or not a PostRequest.

  3. A 400 REST error if the request missing required metadata.

  4. A 400 REST error if the request metadata is missing a required "to" value.

Source

asyncabstract

put(request) → {Promise.<Response>}

Run a PUT request and updates (then returns) objects in storage.

Parameters

  • request PutRequest

    The PUT request to send to the storage engine.

Returns

  • Promise.<Response>

    Returns the data objects from storage that were updated with the request criteria. This may not exactly match the objects requested to be updated, as some may have been deleted from storage or some may not match the key criteria.

Throws

  1. A 501 REST error if not overriden and supported by the storage engine.

  2. A 400 REST error if the request is missing or not a PutRequest.

  3. A 400 REST error if the request missing required metadata.

  4. A 400 REST error if the request metadata is missing a required "to" value.

  5. A 400 REST error if the request metadata is missing at least one "pk" value.

Source

asyncabstract

resources() → {Promise.<Array.<String>>}

Returns an array of strings naming the resources available in the storage medium accessible by the engine.

Returns

  • Promise.<Array.<String>>

Source