Index object

Index object in persistent storage.

Properties

length
- integer, length of an index, number of objects associated represented by the index. Read-only property.
asc
- boolean, direction of access of objects from the index. Write-only property.
[key]
- value, element of the DbIndex at the key position. Read/Write accessor by key. key has to be of the same type as the type of Index object.
If the index was created as non unique then the return value of [] accessor is either undefined or an array - list of items under the key.
[begin..end]
- keys, keys of first and last element of the range. Returns slice of DbIndex which contains elements from start key and up to end key.
begin is a low boundary of key value (if null then there is no low boundary).
end is a high boundary of key value (if null then there is no high boundary).

Methods

add

( key, val [, replace: true|false ] ) : true|false

Inserts val object into Index and associates it with key value. Optionally replaces it with existing object if it exists.

remove
( key [,obj] ) returns: true | false

Method removes object obj by key from the index. Method returns true on success, otherwise false.
If Index is unique, obj is optional.

select

( min-key, max-key [, ascent [, start-inclusive [, end-inclusive]]] ) returns: selection object.

Returns selection in the Index based on criteria min-key, max-key, ascent or descent order, start-inclusive, end-inclusive. Default values:

Example:
var sel = index.select(minVal, maxVal, true);
for( var obj in sel ) { ... }

clear
( ) : undefined

Removes all items from the index object.