timeseries database on leveldb
npm install @konsumation/db-level







timeseries database on leveldb
``js
import levelup from "levelup";
import leveldown from "leveldown";
import { Master, Category } from "konsum-db";
async function example() {
// open database
const db = await levelup(leveldown("example.db"));
const master = await Master.initialize(db);
// create category named EV
const ev = new Category("EV", master, { unit: "kWh" });
await ev.write(master.db);
// write entry
await ev.writeValue(db, Date.now(), 77.34);
}
example();
`
* LevelCategory
* Parameters
* Properties
* write
* Parameters
* key
* meters
* Parameters
* entries
* Parameters
* MASTER
* CATEGORY\_PREFIX
* VALUE\_PREFIX
* METER\_PREFIX
* NOTE\_PREFIX
* LevelMaster
* Properties
* write
* Parameters
* close
* categories
* Parameters
* initialize
* Parameters
* LevelMeter
* Parameters
* Properties
* notes
* Parameters
* values
* Parameters
* key
* LevelNote
* key
* secondsAsString
* Parameters
* LevelValue
* key
Extends Category
Value Category.
* name string category nameoptions
* Object
* options.description string options.unit
* string physical unit like kWh or m3options.fractionalDigits
* number display precission
* name string category namedescription
* string unit
* string physical unitfractionalDigits
* number display precission
* See: {key}
Writes object into database.
Leaves all other entries alone.
#### Parameters
* db ClassicLevel
Returns string
Get Meters of the category.
#### Parameters
* db ClassicLevel options
* Object?
* options.gte string? from nameoptions.lte
* string? up to nameoptions.reverse
* boolean? order
Returns AsyncIterable\
Get categories.
#### Parameters
* db ClassicLevel gte
* (string | undefined) lowest name (optional, default "\u0000")lte
* (string | undefined) highst name (optional, default "\uFFFF")
Returns AsyncIterable\
Prefix of the master record
Type: string
Prefix of the categories.
Will be followed by the category name
Type: string
Prefix of the values.
Will be followed by the category name
Type: string
Prefix of the meters.
Will be followed by the category name
Type: string
Prefix of the notes.
Will be followed by the category name
Type: string
Extends Master
Master record.
Holds schema version.
* schemaVersion string
* See: {key}
Writes object into database.
Leaves all other entries alone.
#### Parameters
* db ClassicLevel
Close the underlaying database.
List Categories.
#### Parameters
* context gte
* string? lte
* string?
Initialize database.
checks/writes master record.
#### Parameters
* directory string
Returns Promise\
Extends Meter
Meter
* name string meter namecategory
* Category options
* Object
* options.description string options.unit
* string physical unit like kWh or m3options.fractionalDigits
* number display precission
* name string category namedescription
* string unit
* string physical unitfractionalDigits
* number display precission
List assigned Notes.
#### Parameters
* db any options
* Object?
Returns AsyncIterable<LevelNote>
Get values of the meter.
#### Parameters
* db any options
* Object?
* options.gte string? time of earliest valueoptions.lte
* string? time of latest valueoptions.reverse
* boolean? order
Returns AsyncIterable\
Returns string
Extends Note
Hints placed on a category at a specific time.
Returns string
Format seconds as string left padded with '0'.
* seconds` number seconds since epoch
Returns string padded seconds
Extends Value
Hints placed on a category at a specific time.
Returns string