@tmlmobilidade/interfaces
Version:
This package provides SDK-style connectors for interacting with databases (e.g., stops, plans, rides, alerts) and external providers (e.g., authentication, storage). It simplifies data access and integration across projects.
38 lines (37 loc) • 1.29 kB
JavaScript
/* * */
import { MongoCollectionClass } from '../../mongo-collection.js';
import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
/* * */
class VehicleEventsClass extends MongoCollectionClass {
static _instance;
constructor() {
super();
}
static async getInstance() {
if (!VehicleEventsClass._instance) {
const instance = new VehicleEventsClass();
await instance.connect();
VehicleEventsClass._instance = instance;
}
return VehicleEventsClass._instance;
}
getCollectionIndexes() {
return [
{ background: true, key: { created_at: 1 } },
{ background: true, key: { received_at: 1 } },
// eslint-disable-next-line perfectionist/sort-objects
{ background: true, key: { trip_id: 1, created_at: 1 } },
{ background: true, key: { agency_id: 1, created_at: 1 } },
// eslint-disable-next-line perfectionist/sort-objects
{ background: true, key: { vehicle_id: 1, created_at: 1 } },
];
}
getCollectionName() {
return 'vehicle_events';
}
getEnvName() {
return 'TML_INTERFACE_VEHICLE_EVENTS';
}
}
/* * */
export const vehicleEvents = AsyncSingletonProxy(VehicleEventsClass);