copyToAsset #
Build the measures
property that will be persisted in the asset document.
By default this method will copy the measures with device and qos information.
copyToAsset (device: Device, request: KuzzleRequest): Promise<AssetMeasures>
Arguments | Type | Description |
---|---|---|
device | Device | Device document |
request | KuzzleRequest | Original request |
Returns #
Returns a promise resolving to an AssetMeasures
.
Usage #
import { KuzzleRequest } from 'kuzzle';
import { Decoder, AssetMeasures } from 'kuzzle-plugin-device-manager';
class KarakoyDecoder extends Decoder {
// [...]
async copyToAsset (device: Device): Promise<AssetMeasures> {
const measures = {};
for (const [measureType, measure] of Object.entries(device._source.measures)) {
measures[measureType] = {
id: device._id,
model: device._source.model,
reference: device._source.reference,
...measure,
qos: device._source.qos,
};
}
return measures;
}
}
This is the default code for the copyToAsset
method.
Edit this page on Github(opens new window)