UNPKG

@citrineos/data

Version:

The OCPP data module which includes all persistence layer implementation.

39 lines 1.59 kB
// SPDX-FileCopyrightText: 2025 Contributors to the CitrineOS Project // // SPDX-License-Identifier: Apache-2.0 import { SequelizeRepository } from './Base.js'; import { Sequelize } from 'sequelize-typescript'; import { Logger } from 'tslog'; import { AsyncJobStatus } from '../model/index.js'; export class SequelizeAsyncJobStatusRepository extends SequelizeRepository { constructor(config, logger, sequelizeInstance) { super(config, AsyncJobStatus.MODEL_NAME, logger, sequelizeInstance); } async createAsyncJobStatus(asyncJobStatus) { return await this._create(asyncJobStatus.tenantId, asyncJobStatus); } async updateAsyncJobStatus(updateData) { const { jobId, ...data } = updateData; // Use the base class method for updating const updated = await this._updateByKey(0, data, jobId); if (!updated) { throw new Error(`Failed to update AsyncJobStatus with id ${jobId}`); } return updated; } // Method for finding by jobId as string (expected by OCPI service) async readByJobId(jobId) { return ((await this.s.models[this.namespace].findOne({ where: { jobId }, })) ?? undefined); } // Method for querying with custom options (expected by OCPI service) async findAllByQuery(query) { return await super.readAllByQuery(0, query); } // Method for deleting by jobId as string (expected by OCPI service) async deleteByJobId(jobId) { return await this._deleteByKey(0, jobId); } } //# sourceMappingURL=AsyncJobStatus.js.map