@citrineos/data
Version:
The OCPP data module which includes all persistence layer implementation.
46 lines • 2.05 kB
JavaScript
;
// Copyright (c) 2023 S44, LLC
// Copyright Contributors to the CitrineOS Project
//
// SPDX-License-Identifier: Apache 2.0
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SequelizeSubscriptionRepository = void 0;
const __1 = require("..");
class SequelizeSubscriptionRepository extends __1.SequelizeRepository {
constructor(config, logger, sequelizeInstance) {
super(config, __1.Subscription.MODEL_NAME, logger, sequelizeInstance);
}
/**
* Creates a new {@link Subscription} in the database.
* Input is assumed to not have an id, and id will be removed if present.
* Object is rebuilt to ensure access to essential {@link Model} function {@link Model.save()} (Model is extended by Subscription).
*
* @param value {@link Subscription} object which may have been deserialized from JSON
* @returns Saved {@link Subscription} if successful, undefined otherwise
*/
create(tenantId, value) {
const rawSubscription = __rest(value, []);
rawSubscription.tenantId = tenantId;
rawSubscription.id = null;
return super.create(tenantId, __1.Subscription.build(Object.assign({}, rawSubscription)));
}
readAllByStationId(tenantId, stationId) {
return super.readAllByQuery(tenantId, { where: { stationId: stationId } });
}
deleteByKey(tenantId, key) {
return super.deleteByKey(tenantId, key);
}
}
exports.SequelizeSubscriptionRepository = SequelizeSubscriptionRepository;
//# sourceMappingURL=Subscription.js.map