timeseries database on leveldb
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
- MASTER
- CATEGORY_PREFIX
- VALUE_PREFIX
- METER_PREFIX
- NOTE_PREFIX
- LevelMaster
- LevelMeter
- LevelNote
- secondsAsString
- LevelValue
Extends Category
Value Category.
name
string category namedescription
stringunit
string physical unitfractionalDigits
number display precission
- See: {key}
Writes object into database. Leaves all other entries alone.
db
ClassicLevel
Returns string
Get Meters of the category.
-
db
ClassicLevel -
options
Object?
Returns AsyncIterable<Meter>
Get categories.
db
ClassicLevelgte
(string | undefined) lowest name (optional, default"\u0000"
)lte
(string | undefined) highst name (optional, default"\uFFFF"
)
Returns AsyncIterable<Category>
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.
db
ClassicLevel
Close the underlaying database.
List Categories.
Initialize database. checks/writes master record.
directory
string
Returns Promise<Master>
Extends Meter
Meter
name
string category namedescription
stringunit
string physical unitfractionalDigits
number display precission
List assigned Notes.
db
anyoptions
Object?
Returns AsyncIterable<LevelNote>
Get values of the meter.
-
db
any -
options
Object?
Returns AsyncIterable<Value>
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