Skip to content

services keyValueService

Baasic edited this page Jan 18, 2017 · 15 revisions

baasicKeyValueService

Baasic Key Value Service provides an easy way to consume Baasic Key Value REST API end-points. In order to obtain needed routes baasicKeyValueService uses baasicKeyValueRouteService.


baasicKeyValueService.find()

Returns a promise that is resolved once the find action has been performed. Success response returns a list of key value resources matching the given criteria.

Example:

baasicKeyValueService.find({
  pageNumber : 1,
  pageSize : 10,
  orderBy : '<field>',
  orderDirection : '<asc|desc>',
  search : '<search-phrase>'
})
.success(function (collection) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});    

baasicKeyValueService.get()

Returns a promise that is resolved once the get action has been performed. Success response returns the specified key value resource.

Example:

baasicKeyValueService.get('<key-value-id>')
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});

baasicKeyValueService.create()

Returns a promise that is resolved once the create key value action has been performed; this action creates a new key value resource.

Example:

baasicKeyValueService.create({
  key : '<key>',
  value : '<value>', 
})
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});

baasicKeyValueService.update()

Returns a promise that is resolved once the update key value action has been performed; this action updates a key value resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply baasicKeyValueRouteService route template. Here is an example of how a route can be obtained from HAL enabled objects:

var params = baasicApiService.removeParams(keyValue);
var uri = params['model'].links('put').href;

Example:

// keyValue is a resource previously fetched using get action.
keyValue.value = '<new-value>';
baasicKeyValueService.update(keyValue)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});

baasicKeyValueService.remove()

Returns a promise that is resolved once the remove action has been performed. This action will remove a key value resource from the system if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply baasicKeyValueRouteService route template. Here is an example of how a route can be obtained from HAL enabled objects:

var params = baasicApiService.removeParams(keyValue);
var uri = params['model'].links('delete').href;

Example:

// keyValue is a resource previously fetched using get action.				 
baasicKeyValueService.remove(keyValue)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});		

baasicKeyValueService.routeService()

Provides direct access to baasicKeyValueRouteService.

Example:

baasicKeyValueService.routeService.get.expand(expandObject);

Notes:

  • Refer to the Baasic REST API for detailed information about available Baasic REST API end-points.
  • All end-point objects are transformed by the associated route service.

(c) 2017 Mono Ltd

Author: Mono Ltd

License: MIT