data model of the konsumation apps
npm install @konsumation/model







Data model of the konsumation apps
* AttributeDefinition
* Properties
* description
* name
* id
* unit
* unit
* schemaVersion
* serial
* validFrom
* fractionalDigits
* fractionalDigits
* order
* value
* date
* isAggregating
* Base
* isDefinedAttribute
* Parameters
* \_getAttributes
* Parameters
* getLocalAttributes
* Parameters
* setAttributes
* Parameters
* type
* attributes
* attributeNameMapping
* Category
* Parameters
* name
* description
* fractionalDigits
* unit
* order
* write
* Parameters
* delete
* Parameters
* meters
* Parameters
* meter
* Parameters
* activeMeter
* Parameters
* addMeter
* Parameters
* deleteMeter
* Parameters
* notes
* Parameters
* note
* Parameters
* values
* Parameters
* value
* Parameters
* latestValue
* Parameters
* addValue
* Parameters
* deleteValue
* Parameters
* text
* Parameters
* type
* SCHEMA\_VERSION\_2
* SCHEMA\_VERSION\_3
* SCHEMA\_VERSION\_CURRENT
* Master
* Parameters
* Properties
* one
* Parameters
* all
* Parameters
* write
* Parameters
* close
* addCategory
* Parameters
* categories
* Parameters
* category
* Parameters
* text
* Parameters
* fromText
* Parameters
* initialize
* Parameters
* Meter
* Parameters
* name
* category
* description
* serial
* validFrom
* isAggregating
* write
* Parameters
* delete
* Parameters
* values
* Parameters
* value
* Parameters
* addValue
* Parameters
* deleteValue
* Parameters
* latestValue
* Parameters
* notes
* Parameters
* note
* Parameters
* addNote
* Parameters
* deleteNote
* Parameters
* text
* Parameters
* type
* parentType
* Note
* Parameters
* name
* description
* meter
* write
* Parameters
* delete
* Parameters
* text
* Parameters
* type
* parentType
* toText
* Parameters
* Value
* Parameters
* meter
* date
* value
* write
* Parameters
* delete
* Parameters
* text
* Parameters
* type
* parentType
Type: Object
* type string
* regex RegExp?
* isKey boolean
* isForeign boolean do we represent a foreign entity
* writable boolean
* mandatory boolean
* default any? the default value
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Returns string
Type: string?
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: number?
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Is the given attribute defined in the target.
Some attributes are inherited from parent object and therfore not defined in the target.
#### Parameters
* name string
Returns boolean
Object keys are the mapped external attribute names.
#### Parameters
* mapping
Returns Object
Object keys are the mapped external attribute names but only for local (not isForeign) ones.
#### Parameters
* mapping
Returns Object
Sets values with external attribute names.
#### Parameters
* values Object
Returns string
Attribute definitions.
Returns Object
Maping of attribute names from internal (javascript) to external (database).
Returns Object
Extends Base
Value Category.
* attributes Object
Type: string
Type: string?
Type: number?
Type: string?
Type: string?
Write into store.
#### Parameters
* context any
Delete Category from store.
#### Parameters
* context any
List assigned meters.
#### Parameters
* context any
* options Object?
* options.gte string? from name
* options.lte string? up to name
* options.reverse boolean? order
Returns AsyncIterable<Meter>
Deliver Meter for a given name.
#### Parameters
* context any
* name string
Returns Promise<(Meter | undefined)>
Currently active Meter.
#### Parameters
* context any
* create boolean Meter if none exist (optional, default false)
Returns Promise<(Meter | undefined)>
Add a meter to the category;
#### Parameters
* context any
* attributes Object
* attributes.name string
* attributes.category Category?
* attributes.validFrom Date?
* attributes.description string?
* attributes.serial string?
* attributes.fractionalDigits number?
* attributes.unit string?
Returns Meter
Delete a meter.
#### Parameters
* context any
* name string
Returns Promise\
All notes from all meters.
#### Parameters
* context any
Returns AsyncIterable<Note>
Deliver Value for a given date.
#### Parameters
* context any
* name string
Returns Promise<(Note | undefined)>
All values from all meters.
#### Parameters
* context any
Returns AsyncIterable<Value>
Deliver Value for a given date.
#### Parameters
* context any
* date Date
Returns Promise<(Value | undefined)>
Get the latest value.
#### Parameters
* context any
Returns Promise<({date: Date, value: number} | undefined)>
Add a value to the active meter.
#### Parameters
* context any
* attributes Object
* attributes.date Date
* attributes.value number
Returns Promise\
Delete a value from the active meter.
#### Parameters
* context any
* date Date
Returns Promise\
Text representation.
#### Parameters
* context any
Returns AsyncIterable<string>
Name of the type in text dump
Returns string
Schema with type + name
Type: string
Values are attached to the meter.
Value dates may be given as iso date.
Type: string
Schema version for newly created databases
Extends Base
* values
* schemaVersion string
Query for one item.
#### Parameters
* query Object
* query.category string?
* query.meter string?
* query.note string?
* query.date (string | Date)?
Returns Promise<(Category | Meter | Note | Value | undefined)>
Query for several items.
#### Parameters
* query Object
* query.category string?
* query.meter string?
* query.note string?
* query.date (string | Date)?
Returns AsyncIterable<(Category | Meter | Note | Value)>
Write attributes store.
#### Parameters
* context any
Shut down backend store.
Add a category.
#### Parameters
* context any
* attributes Object
* attributes.name string
* attributes.description string?
* attributes.fractionalDigits number?
* attributes.unit string?
Returns Category
#### Parameters
* context any
Returns AsyncIterable<Category>
#### Parameters
* context any
* name string
Returns Promise<(Category | undefined)>
Create text representation
#### Parameters
* context (optional, default this.context)
Returns AsyncIterable<string>
#### Parameters
* input AsyncIterable<Uint8Array>
#### Parameters
Extends Base
* attributes Object
Type: string
Type: Category
Type: string?
Type: string?
Type: Date
Type: boolean
#### Parameters
* context any
#### Parameters
* context any
#### Parameters
* context any
Returns AsyncIterable<Value>
Deliver value for a given date.
#### Parameters
* context any
* date Date
Returns Promise<(Value | undefined)>
Add a new value.
#### Parameters
* context any
* attributes Object
* attributes.date Date
* attributes.value number
Delete a value.
#### Parameters
* context any
* date Date
Returns Promise\
Get the latest value.
#### Parameters
* context any
Returns Promise<(Value | undefined)>
List assigned Notes.
#### Parameters
* context any
* options Object?
Returns AsyncIterable<Note>
Deliver Note for a given name.
#### Parameters
* context any
* name string
Returns Promise<(Note | undefined)>
Add a note to the meter;
#### Parameters
* context any
* attributes Object
* attributes.name string
* attributes.meter Meter
* attributes.description string?
Returns Note
delete a note.
#### Parameters
* context any
* name string
Returns Promise\
Text representation.
#### Parameters
* context any
Returns AsyncIterable<string>
Name of the type in text dump.
Returns string
Name of the parents type.
Returns string
Extends Base
* attributes Object
Type: string
Type: string?
Type: Meter
Write into store.
#### Parameters
* context any
Delete from store.
#### Parameters
* context any
Text representation.
#### Parameters
* context any
Returns AsyncIterable<string>
Name of the type in text dump.
Returns string
Name of the parents type.
Returns string
Text representation.
* context any
* object Base
* key string?
* iterators ...any
Returns AsyncIterable<string>
Extends Base
* attributes Object
Type: Meter
Type: Date
Type: number
Write into store.
#### Parameters
* context any
Delete from store.
#### Parameters
* context any
Text representation.
#### Parameters
* context any
Returns AsyncIterable<string>
Name of the type in text dump
Returns string
Name of the parents type.
Returns string
With npm do:
``shell``
npm install @konsumation/model
BSD-2-Clause