Class: ScopeApi

ScopeApi

new ScopeApi()

Common behaviour for record scopes.

Record scopes are starting points for record operations (like base type or a collection)

TODO: Talk about record building here

Source:
  • module/api/scope-api.js, line 5

Methods

$build(_init) → {RecordApi}

Builds a new instance of this model, does not assign a pk to the created object.

ATTENTION: item will not show in collection until $save is called. To reveal item before than call $reveal.

Parameters:
Name Type Description
_init object

Initial values

Source:
  • module/api/scope-api.js, line 53
Returns:

single record

Type
RecordApi

$buildRaw(_raw) → {RecordApi}

Builds a new instance of this model using undecoded data.

ATTENTION: does not automatically reveal item in collection, chain a call to $reveal to do so.

Parameters:
Name Type Description
_raw object

Undecoded data

Source:
  • module/api/scope-api.js, line 67
Returns:

single record

Type
RecordApi

$collection(_params, _scope) → {CollectionApi}

Builds a new collection bound to this scope.

If scope is another collection then it will inherit its parameters

Collections are bound to an api resource.

Parameters:
Name Type Description
_params object

Additional query string parameters

_scope object

Scope override (optional)

Source:
  • module/api/scope-api.js, line 111
Returns:

Model Collection

Type
CollectionApi

$create(_attr) → {RecordApi}

Builds and saves a new instance of this model

Parameters:
Name Type Description
_attr object

Data to be saved

Source:
  • module/api/scope-api.js, line 94
Returns:

single record

Type
RecordApi

$find(_pk, _params) → {RecordApi}

Attempts to resolve a resource using provided private key.

Parameters:
Name Type Description
_pk mixed

Private key

_params object

Additional query parameters

Source:
  • module/api/scope-api.js, line 82
Returns:

single record

Type
RecordApi

$new(_pk, _scope) → {RecordApi}

Builds a new instance of this model, bound to this instance scope, sets its primary key.

Parameters:
Name Type Description
_pk mixed

object private key

_scope object

scope override (optional)

Source:
  • module/api/scope-api.js, line 39
Returns:

New model instance

Type
RecordApi

$search(_params) → {CollectionApi}

Generates a new collection bound to this context and url and calls $fetch on it.

Parameters:
Name Type Description
_params object

Collection parameters

Source:
  • module/api/scope-api.js, line 123
Returns:

record collection

Type
CollectionApi

$urlFor(_resource) → {string|null}

provides urls for scope's resources.

Parameters:
Name Type Description
_resource mixed

The target resource.

Source:
  • module/api/scope-api.js, line 24
Returns:

The url or nill if resource does not meet the url requirements.

Type
string | null