@konsumation/model
Data model of the konsumation apps
API
Table of Contents
AttributeDefinition
Type: Object
Properties
description
Type: AttributeDefinition
name
Type: AttributeDefinition
id
Type: AttributeDefinition
unit
Type: AttributeDefinition
Returns string
unit
Type: string?
schemaVersion
Type: AttributeDefinition
serial
Type: AttributeDefinition
validFrom
Type: AttributeDefinition
fractionalDigits
Type: AttributeDefinition
fractionalDigits
Type: number?
order
Type: AttributeDefinition
Base
attributeNames
Attribute names on the javascript side.
Returns Array<string>
getAttributes
Object keys are the mapped external attribute names.
Returns Object
setAttributes
Sets values with external attribute names.
Parameters
type
Returns string
attributes
Attribute definitions.
Returns Object
attributeNameMapping
Maping of attribute names from internal (javascript) to external (database).
Returns Object
attributeNames
Attribute names on the javascript side.
Returns Array<string>
Category
Extends Base
Value Category.
Parameters
name
Type: string
description
Type: string?
fractionalDigits
Type: number?
unit
Type: string?
order
Type: string?
write
Write into store.
Parameters
delete
Delete Category from store.
Parameters
meters
List assigned meters.
Parameters
Returns AsyncIterable<Meter>
meter
Deliver Meter for a given name.
Parameters
Returns Promise<(Meter | undefined)>
activeMeter
Currently active Meter.
Parameters
Returns Promise<(Meter | undefined)>
addMeter
Add a meter to the category;
Parameters
values
Object (optional, default {}
)
Returns Promise<Meter>
notes
All notes from all meters.
Parameters
Returns AsyncIterable<Note>
values
All values from all meters.
Parameters
Returns AsyncIterable<{date: Date, value: number}>
latestValue
Get the latest value.
Parameters
Returns Promise<({date: Date, value: number} | undefined)>
writeValue
Add a value to the active meter.
Parameters
Returns Promise<any>
deleteValue
Delete a value from the active meter.
Parameters
Returns Promise<any>
text
Text representation.
Parameters
Returns AsyncIterable<string>
type
Name of the type in text dump
Returns string
SCHEMA_VERSION_2
Schema with type + name
Type: string
SCHEMA_VERSION_3
Values are attached to the meter.
Value dates may be given as iso date.
Type: string
SCHEMA_VERSION_CURRENT
Schema version for newly created databases
Master
Extends Base
Parameters
Properties
write
Write attributes store.
Parameters
close
addCategory
Add a category.
Parameters
Returns Promise<Category>
categories
Returns AsyncIterable<Category>
category
Parameters
Returns Promise<(Category | undefined)>
text
Create text representation
Returns AsyncIterable<string>
initialize
Parameters
Returns Promise<Master>
Meter
Extends Base
Parameters
name
Type: string
category
Type: Category
description
Type: string?
serial
Type: string?
validFrom
Type: Date?
write
Parameters
delete
Parameters
values
Parameters
Returns AsyncIterable<{date: Date, value: number}>
writeValue
Write new value.
Parameters
deleteValue
Delete a value.
Parameters
latestValue
Get the latest value.
Parameters
Returns Promise<({date: Date, value: number} | undefined)>
notes
List assigned Notes.
Parameters
Returns AsyncIterable<Note>
addNote
Add a note to the meter;
Parameters
values
Object (optional, default {}
)
Returns Promise<Note>
text
Text representation.
Parameters
Returns AsyncIterable<string>
type
Name of the type in text dump
Returns string
Note
Extends Base
Parameters
name
Type: string
description
Type: string?
meter
Type: Meter
write
Write into store.
Parameters
delete
Delete from store.
Parameters
text
Text representation.
Parameters
Returns AsyncIterable<string>
type
Name of the type in text dump
Returns string
toText
Text representation.
Parameters
context
any object
Base key
string iterators
...any
Returns AsyncIterable<string>
install
With npm do:
npm install @konsumation/model
license
BSD-2-Clause