Skip to content
mzilic edited this page Mar 31, 2015 · 15 revisions

Key-Value Module

Baasic AngularJS Key-Value services and their functions can be found bellow. For further details please check the API documentation

SDK Documentation

baasicKeyValueService

Baasic Key-Value Service provides an easy way to consume Baasic Key-Value REST API.

  • get - Gets a single key-value resource by Id
  • find - Finds key-value resources by given criteria
  • create - Creates a new key-value resource
  • update - Updates a key-value resource
  • remove - Deletes a key-value resource
  • routeService - Provides direct access to baasicKeyValueRouteService

Here are a few examples on how to use the baasicKeyValueService:

var id = "myKey";
baasicKeyValueService.get(id)
    .success(function(data) {
        // data variable contains a single key-value object that match the key/id
    });
var options = { searchQuery: "myQuery", page: 1, rpp: 10 };
baasicKeyValueService.find(options)
    .success(function(data) {
        // data variable contains a collection of key-value objects that match the filtering parameters
    });

Note For functions such as update and remove that don't use baasicKeyValueRouteService for obtaining route templates, routes can be obtained from key-value (HAL enabled) objects like this:

var params = baasicApiService.removeParams(keyValueObject);
var uri = params["model"].links('delete').href;
// i.e. if the keyValueObject had the following id: "myKey"
// the uri would yield "/key-values/myKey"

baasicKeyValueRouteService

Baasic Key-Value Route Service provides Baasic route templates which can be expanded to Baasic REST URI's through the URI Template by providing it with an object that contains URI parameters. baasicKeyValueService uses baasicKeyValueRouteService to obtain a part of needed routes while the other part is obtained through HAL. baasicKeyValueRouteService by convention uses the same function names as baasicKeyValueService.

Here is a list of all the baasicKeyValueRouteService functions:

  • get, find, create
  • parse - Provides direct access to the uriTemplateService

URI templates can be expanded manually like this:

var params = { searchQuery: "myQuery", page: 1, rpp: 10 };
var uri = baasicKeyValueRouteService.find.expand(params);
// uri will yield "/key-values/?searchQuery=<search-phrase>&page=1&rpp=10"
Clone this wiki locally