Asset

Stack# Asset

Methods

(static) getAssetsOfSpecificTypes(assetType) → {external:Promise}

Source:
This static method retrieves assets that are either image or video files, based on the request query.
Parameters:
Name Type Description
assetType String Type of asset to be received for e.g., ‘image/png’
Returns:
Type
external:Promise

(static) getRteAssets() → {external:Promise}

Source:
This static method retrieves comprehensive information on all assets uploaded through the Rich Text Editor field.
Returns:
Type
external:Promise

(static) Query() → {Query}

Source:
This static method instantiates the query module for assets. To see the list of methods that can be used for querying assets, refer the Query module.
Example
let assetQuery = extension.stack.Asset.Query();
assetQuery.where("title": "main.js").limit(10).skip(10).find().then(...).catch(...);
Returns:
Type
Query

addParam(key, value) → {Stack#Asset}

Source:
This method includes a query parameter in your query.
Example
extension.stack.Asset('uid').addParam('key', 'value').fetch().then().catch();
   
Parameters:
Name Type Description
key string Key of the parammeter
value string Value of the parammeter
Returns:
Type
Stack#Asset

addQuery(key, value) → {Stack#Asset}

Source:
This method includes a query parameter in your query.
Example
extension.stack.Asset('uid').addQuery('key', 'value').fetch().then().catch();
   
Parameters:
Name Type Description
key string Key of the parammeter
value string Value of the parammeter
Returns:
Type
Stack#Asset

delete() → {external:Promise}

Source:
See:
This method deletes an existing asset.
Example
extension.stack.Asset('uid').delete().then().catch();
   
Returns:
Type
external:Promise

environment(environment_uid) → {Stack#Asset}

Source:
This method is used to set the environment name of which you want to retrieve the data.
Example
extension.stack.Asset('bltsomething123').environment('development').fetch()
Parameters:
Name Type Description
environment_uid String UID/Name of environment
Returns:
Type
Stack#Asset

except(keyopt, values) → {Stack#Asset}

Source:
This method is used to hide the selected fields of the assets in result set.
Examples

.Except with the field UID

extension.stack.Asset('bltsomething123').except('title').fetch();

.Except with the field UID

extension.stack.Asset('bltsomething123').except('BASE','title').fetch();

.Except with the field UIDs(array)

extension.stack.Asset('bltsomething123').except(['title','description']).fetch();
Parameters:
Name Type Attributes Default Description
key String <optional>
BASE Single field of an asset
values Array Array of fields to be hidden in the result set
Returns:
Type
Stack#Asset

getReferences() → {external:Promise}

Source:
See:
This method will fetch the details of the entries and the assets in which the specified asset is referenced.
Example
extension.stack.Asset('uid').getReferences().then().catch();
   
Returns:
Type
external:Promise

only(keyopt, values) → {Stack#Asset}

Source:
This method is used to show the selected fields of the assets in the result set.
Examples

Only with the field UID

extension.stack.Asset('bltsomething123').only('title').fetch();

Only with the field UID

extension.stack.Asset('bltsomething123').only('BASE','title').fetch();

Only with the field UIDs(array)

extension.stack.Asset('bltsomething123').only(['title','description']).fetch();
Parameters:
Name Type Attributes Default Description
key String <optional>
BASE Single field of an asset
values Array Array of fields to be shown in the result set
Returns:
Type
Stack#Asset

publish(payload) → {external:Promise}

Source:
This method allows you to publish the asset either immediately or schedule the publish for a later date/time.
Example
extension.stack.Asset('bltsomething123')
   .publish(
     {
        "asset": {
          "locales": [
            "en-us"
          ],
          "environments": [
            "development"
          ]
        },
        "version": 1,
        "scheduled_at": "2019-02-08T18:30:00.000Z"
      });
Parameters:
Name Type Description
payload object Payload for the request.
Returns:
Type
external:Promise

unpublish(payload) → {external:Promise}

Source:
This method will instantly unpublish the asset, and also give you the provision to automatically unpublish the asset at a later date/time.
Example
extension.stack.Asset('bltsomething123')
    .unpublish({
    "asset": {
      "locales": [
        "en-us"
      ],
      "environments": [
        "development"
      ]
    },
    "version": 1,
    "scheduled_at": "2019-02-08T18:30:00.000Z"
  });
Parameters:
Name Type Description
payload object Payload for the request.
Returns:
Type
external:Promise