@citrineos/data
Version:
The OCPP data module which includes all persistence layer implementation.
98 lines • 3.68 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { DEFAULT_TENANT_ID, Namespace } from '@citrineos/base';
import { BeforeCreate, BeforeUpdate, BelongsTo, Column, DataType, ForeignKey, Model, Table, } from 'sequelize-typescript';
import { TransactionEvent } from './TransactionEvent.js';
import { Transaction } from './Transaction.js';
import { StopTransaction } from './StopTransaction.js';
import { Tenant } from '../Tenant.js';
import { Tariff } from '../Tariff/index.js';
let MeterValue = class MeterValue extends Model {
static MODEL_NAME = Namespace.MeterValue;
static setDefaultTenant(instance) {
if (instance.tenantId == null) {
instance.tenantId = DEFAULT_TENANT_ID;
}
}
constructor(...args) {
super(...args);
if (this.tenantId == null) {
this.tenantId = DEFAULT_TENANT_ID;
}
}
};
__decorate([
ForeignKey(() => TransactionEvent),
Column(DataType.INTEGER),
__metadata("design:type", Object)
], MeterValue.prototype, "transactionEventId", void 0);
__decorate([
ForeignKey(() => Transaction),
Column(DataType.INTEGER),
__metadata("design:type", Object)
], MeterValue.prototype, "transactionDatabaseId", void 0);
__decorate([
ForeignKey(() => StopTransaction),
Column(DataType.INTEGER),
__metadata("design:type", Object)
], MeterValue.prototype, "stopTransactionDatabaseId", void 0);
__decorate([
Column(DataType.JSONB),
__metadata("design:type", Array)
], MeterValue.prototype, "sampledValue", void 0);
__decorate([
Column({
type: DataType.DATE,
get() {
return this.getDataValue('timestamp').toISOString();
},
}),
__metadata("design:type", String)
], MeterValue.prototype, "timestamp", void 0);
__decorate([
Column(DataType.INTEGER),
__metadata("design:type", Number)
], MeterValue.prototype, "connectorId", void 0);
__decorate([
ForeignKey(() => Tariff),
Column(DataType.INTEGER),
__metadata("design:type", Object)
], MeterValue.prototype, "tariffId", void 0);
__decorate([
Column(DataType.STRING),
__metadata("design:type", Object)
], MeterValue.prototype, "transactionId", void 0);
__decorate([
ForeignKey(() => Tenant),
Column({
type: DataType.INTEGER,
allowNull: false,
onUpdate: 'CASCADE',
onDelete: 'RESTRICT',
}),
__metadata("design:type", Number)
], MeterValue.prototype, "tenantId", void 0);
__decorate([
BelongsTo(() => Tenant),
__metadata("design:type", Object)
], MeterValue.prototype, "tenant", void 0);
__decorate([
BeforeUpdate,
BeforeCreate,
__metadata("design:type", Function),
__metadata("design:paramtypes", [MeterValue]),
__metadata("design:returntype", void 0)
], MeterValue, "setDefaultTenant", null);
MeterValue = __decorate([
Table,
__metadata("design:paramtypes", [Object])
], MeterValue);
export { MeterValue };
//# sourceMappingURL=MeterValue.js.map