Skip to content
pgte edited this page Dec 30, 2010 · 2 revisions

KeyMap with a key index (in memory).

Inherits from KeyMap.

Also provides atomic operations on individual records.

And provides all these additional methods:

indexed_key_map.eachInIndex (callback)

Iterates over the index and retrieves all the records.

  • callback (err, key, value): called for every record fetched or when there is an error.

indexed_key_map.atomic (key, callback, result_callback)

With this function you can do atomic operations on a record.

  • key: the key of the record you are looking for
  • callback (err, record): invoked when there is an error. In this case first argument will contain an error. If not, will contain the record on the second argument if key was found. If not, record will be null. This callback should return the new value.
  • result_callback (err): called when the saving of the record finishes. If an error occurred saving the object the first argument will contain that error.

indexed_key_map.compact (callback)

Compact the key_map, loosing all past history.

You can keep reading and writing the database meanwhile.

  • callback (err): when compacting finishes (err = null) or an error occurs.