@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
value
Type: AttributeDefinition
date
Type: AttributeDefinition
Base
attributeNames
Attribute names on the javascript side.
Returns Array<string>
getAttributes
Object keys are the mapped external attribute names.
Returns Object
getLocalAttributes
Object keys are the mapped external attribute names but only for local (not isForeign) ones.
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
Returns Meter
notes
All notes from all meters.
Parameters
Returns AsyncIterable<Note>
values
All values from all meters.
Parameters
Returns AsyncIterable<{date: Date, value: number}>
value
Deliver Value for a given date.
Parameters
Returns Promise<({date: Date, value: number} | undefined)>
latestValue
Get the latest value.
Parameters
Returns Promise<({date: Date, value: number} | undefined)>
addValue
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 Category
categories
Parameters
Returns AsyncIterable<Category>
category
Parameters
Returns Promise<(Category | undefined)>
text
Create text representation
Parameters
context
(optional, default this.context
)
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<{Value}>
value
Deliver Value for a given date.
Parameters
Returns Promise<(Value | undefined)>
addValue
add new value.
Parameters
Returns Promise<Value>
deleteValue
delete value.
Parameters
Returns Promise<void>
latestValue
Get the latest value.
Parameters
Returns Promise<(Value | undefined)>
notes
List assigned Notes.
Parameters
Returns AsyncIterable<Note>
note
Deliver Note for a given name.
Parameters
Returns Promise<(Note | undefined)>
addNote
Add a note to the meter;
Parameters
Returns 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>
Value
Extends Base
Parameters
meter
Type: Meter
date
Type: Date
value
Type: number
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
install
With npm do:
npm install @konsumation/model
license
BSD-2-Clause