Table Of Contents

aps/Memory

This is a basic in-memory object store. It implements ``dojo.store.api.Store``.

Compatibility

All user panels - CP and UX1

Examples

var data = [{
        aps: {id: "1"},
        info: {title: "Server 1"},
        params: {
            disk: 152,
            ram: 199,
            cpu: 2
        }
    }, {
        aps: {id: "2"},
        info: {title: "Server 2"},
        params: {
            disk: 152,
            ram: 917,
            cpu: 965
        }
    }];

var store = new Memory({
    data: data,
    idProperty: "aps.id"
});

Public Properties

PROPERTY

TYPE

DEFAULT

DESCRIPTION

baseQuery

string

null

RQL statement that will be added to every request for a list of resources.

childrenProperty

string

undefined

The name of property in data object that contains list of sub objects.

baseQuery string

RQL statement that will be added to every request for a list of resources. Default value: null.

childrenProperty string

The name of property in data object that contains list of sub objects. Default value: undefined.

Public Methods

METHOD

RETURN

DESCRIPTION

getIdentity (object)

number

Returns an object’s identity

mapQuery (row)

row
object

Method for preparing data before completing request

put (object, options)

Stores an object

query (query, options)

dojo/store/api/store.queryresults

Queries the store for objects

setData (data)

undefined

Sets the given data as the source for this store, and indexes it

getIdentity

Returns an object’s identity.

Return: number

ARGUMENT

TYPE

DESCRIPTION

object

Object

The object to get the identity from.

mapQuery

Method for preparing data before completing request.

Return: row object

ARGUMENT

TYPE

DESCRIPTION

row

Object

Received from server row which must be processed.

put

Stores an object.

ARGUMENT

TYPE

DESCRIPTION

object

Object

The object to store.

options

Store.PutDirectives

Additional metadata for storing the data. Includes an “id” property if a specific id is to be used. returns: Number

query

Queries the store for objects.

Return: dojo/store/api/store.queryresults

ARGUMENT

TYPE

DESCRIPTION

query

Object

The query to use for retrieving objects from the store.

options

Object

The additional parameters sent to the originating _SearchMixin’s store, including: start, count, queryOptions.

Example 1

Given the following store:

var store = new Memory({
    data: [
        {id: 1, name: "one", prime: false },
        {id: 2, name: "two", even: true, prime: true},
        {id: 3, name: "three", prime: true},
        {id: 4, name: "four", even: true, prime: false},
        {id: 5, name: "five", prime: true}
    ]
});

…find all items where “prime” is true:

var results = store.query({ prime: true });

…or find all items where “even” is true:

var results = store.query({ even: true });

setData

Sets the given data as the source for this store, and indexes it

Return: undefined

ARGUMENT

TYPE

DESCRIPTION

data

Object[]

An array of objects to use as the source of data.