BucketPrefix

BucketPrefix

Provides methods to parse path parameters.

Constructor

new BucketPrefix(model)

Source:
Parameters:
Name Type Description
model Model

Model instance.

Example
const prefix = new BucketPrefix(modelFoo);

Methods

getParam(pos) → {String}

Return path parameter for a given position.

Example: Bucket Prefix /foo/bar/biz/baz Position | 1 | 2 | 3 | 4

Source:
Parameters:
Name Type Default Description
pos Number 1

Bucket Prefix position (default: 1).

Returns:
Type:
String
Example
const param = prefix.getParam(2);
// bar

lastParam() → {String}

Return path last parameter.

Source:
Returns:
Type:
String
Example
const param = prefix.lastParam();
// baz

params() → {Array.<String>}

Return array of path parameters (ordered by index).

Source:
Returns:
Type:
Array.<String>
Example
const params = prefix.params();
// ['foo', 'bar', 'biz', 'baz']

path() → {String}

Return path relative to Model position.

Source:
Returns:
Type:
String
Example
const param = prefix.path();
// foo/bar/biz/baz

rootParam() → {String}

Return path root parameter.

Source:
Returns:
Type:
String
Example
const param = prefix.rootParam();
// foo