@konsumation/model
v7.3.0
Published
data model of the konsumation apps
Downloads
1,440
Readme
@konsumation/model
Data model of the konsumation apps
API
Table of Contents
- AttributeDefinition
- description
- name
- id
- unit
- unit
- schemaVersion
- serial
- validFrom
- fractionalDigits
- fractionalDigits
- order
- value
- date
- Base
- Category
- SCHEMA_VERSION_2
- SCHEMA_VERSION_3
- SCHEMA_VERSION_CURRENT
- Master
- Meter
- Note
- toText
- Value
AttributeDefinition
Type: Object
Properties
type
stringregex
RegExp?isKey
booleanisForeign
boolean do we represent a foreign entitywritable
booleanmandatory
booleandefault
any? the default value
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
isDefinedAttribute
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
_getAttributes
Object keys are the mapped external attribute names.
Parameters
mapping
Returns Object
getLocalAttributes
Object keys are the mapped external attribute names but only for local (not isForeign) ones.
Parameters
mapping
Returns Object
setAttributes
Sets values with external attribute names.
Parameters
values
Object
type
Returns string
attributes
Attribute definitions.
Returns Object
attributeNameMapping
Maping of attribute names from internal (javascript) to external (database).
Returns Object
Category
Extends Base
Value Category.
Parameters
attributes
Object
name
Type: string
description
Type: string?
fractionalDigits
Type: number?
unit
Type: string?
order
Type: string?
write
Write into store.
Parameters
context
any
delete
Delete Category from store.
Parameters
context
any
meters
List assigned meters.
Parameters
context
anyoptions
Object?
Returns AsyncIterable<Meter>
meter
Deliver Meter for a given name.
Parameters
context
anyname
string
Returns Promise<(Meter | undefined)>
activeMeter
Currently active Meter.
Parameters
context
anycreate
boolean Meter if none exist (optional, defaultfalse
)
Returns Promise<(Meter | undefined)>
addMeter
Add a meter to the category;
Parameters
context
anyattributes
Object
Returns Meter
deleteMeter
Delete a meter.
Parameters
context
anyname
string
Returns Promise<any>
notes
All notes from all meters.
Parameters
context
any
Returns AsyncIterable<Note>
note
Deliver Value for a given date.
Parameters
context
anyname
string
Returns Promise<(Note | undefined)>
values
All values from all meters.
Parameters
context
any
Returns AsyncIterable<Value>
value
Deliver Value for a given date.
Parameters
context
anydate
Date
Returns Promise<(Value | undefined)>
latestValue
Get the latest value.
Parameters
context
any
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
context
anydate
Date
Returns Promise<any>
text
Text representation.
Parameters
context
any
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
values
Properties
schemaVersion
string
one
Query for one item.
Parameters
query
Object
Returns Promise<(Category | Meter | Note | Value | undefined)>
all
Query for several items.
Parameters
query
Object
Returns AsyncIterable<(Category | Meter | Note | Value)>
write
Write attributes store.
Parameters
context
any
close
Shut down backend store.
addCategory
Add a category.
Parameters
context
anyattributes
Object
Returns Category
categories
Parameters
context
any
Returns AsyncIterable<Category>
category
Parameters
context
anyname
string
Returns Promise<(Category | undefined)>
text
Create text representation
Parameters
context
(optional, defaultthis.context
)
Returns AsyncIterable<string>
fromText
Parameters
input
AsyncIterable<Uint8Array>
initialize
Parameters
Meter
Extends Base
Parameters
attributes
Object
name
Type: string
category
Type: Category
description
Type: string?
serial
Type: string?
validFrom
Type: Date
write
Parameters
context
any
delete
Parameters
context
any
values
Parameters
context
any
Returns AsyncIterable<Value>
value
Deliver value for a given date.
Parameters
context
anydate
Date
Returns Promise<(Value | undefined)>
addValue
Add a new value.
Parameters
deleteValue
Delete a value.
Parameters
context
anydate
Date
Returns Promise<void>
latestValue
Get the latest value.
Parameters
context
any
Returns Promise<(Value | undefined)>
notes
List assigned Notes.
Parameters
context
anyoptions
Object?
Returns AsyncIterable<Note>
note
Deliver Note for a given name.
Parameters
context
anyname
string
Returns Promise<(Note | undefined)>
addNote
Add a note to the meter;
Parameters
context
anyattributes
Object
Returns Note
deleteNote
delete a note.
Parameters
context
anyname
string
Returns Promise<void>
text
Text representation.
Parameters
context
any
Returns AsyncIterable<string>
type
Name of the type in text dump.
Returns string
parentType
Name of the parents type.
Returns string
Note
Extends Base
Parameters
attributes
Object
name
Type: string
description
Type: string?
meter
Type: Meter
write
Write into store.
Parameters
context
any
delete
Delete from store.
Parameters
context
any
text
Text representation.
Parameters
context
any
Returns AsyncIterable<string>
type
Name of the type in text dump.
Returns string
parentType
Name of the parents type.
Returns string
toText
Text representation.
Parameters
Returns AsyncIterable<string>
Value
Extends Base
Parameters
attributes
Object
meter
Type: Meter
date
Type: Date
value
Type: number
write
Write into store.
Parameters
context
any
delete
Delete from store.
Parameters
context
any
text
Text representation.
Parameters
context
any
Returns AsyncIterable<string>
type
Name of the type in text dump
Returns string
parentType
Name of the parents type.
Returns string
install
With npm do:
npm install @konsumation/model
license
BSD-2-Clause