Home Reference Source Test
public interface | source

ICodec

This interface represents a codec. A codec is used to encode values before storing them into the database and to decode values when retrieving them from the database. The codec is only applies when storing/retrieving values in/from the backend.

WARNING: By contract, it is required that decode(key, encode(obj)) == obj. If this assumption is violated, unexpected behaviour might occur.

LIMITATION: IndexedDB indices will use the encoded values, while all other implementations build their indices on the decoded values.

Member Summary

Public Members
public get

leveldbValueEncoding: ILevelDBEncoding

A value encoding used only for the levelDB implementation and ignored for the indexedDB.

public get

A value encoding used only for the LMDB implementation and ignored for the indexedDB.

public get

valueEncoding: ILMDBEncoding | ILevelDBEncoding | void

A value encoding used for the levelDB and LMDB implementation and ignored for the indexedDB.

Method Summary

Public Methods
public abstract

decode(obj: *, key: string): *

Decodes an object before returning it to the user.

public abstract

encode(obj: *): *

Encodes an object before storing it in the database.

Public Members

public get leveldbValueEncoding: ILevelDBEncoding source

A value encoding used only for the levelDB implementation and ignored for the indexedDB. For example, JungleDB.JSON_ENCODING provides a slightly modified JSON encoding supporting UInt8Arrays and Sets.

public get lmdbValueEncoding: ILMDBEncoding source

A value encoding used only for the LMDB implementation and ignored for the indexedDB. For example, JungleDB.JSON_ENCODING provides a slightly modified JSON encoding supporting UInt8Arrays and Sets.

public get valueEncoding: ILMDBEncoding | ILevelDBEncoding | void source

A value encoding used for the levelDB and LMDB implementation and ignored for the indexedDB. For example, JungleDB.JSON_ENCODING provides a slightly modified JSON encoding supporting UInt8Arrays and Sets.

Public Methods

public abstract decode(obj: *, key: string): * source

Decodes an object before returning it to the user.

Params:

NameTypeAttributeDescription
obj *

The object to decode.

key string

The object's primary key.

Return:

*

Decoded object.

public abstract encode(obj: *): * source

Encodes an object before storing it in the database.

Params:

NameTypeAttributeDescription
obj *

The object to encode before storing it.

Return:

*

Encoded object.