@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.
36 lines (35 loc) • 1.08 kB
JavaScript
/* * */
import { MongoCollectionClass } from '../../mongo-collection.js';
import { HashedTripSchema, UpdateHashedTripSchema } from '@tmlmobilidade/types';
import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
/* * */
class HashedTripsClass extends MongoCollectionClass {
static _instance;
createSchema = HashedTripSchema;
updateSchema = UpdateHashedTripSchema;
constructor() {
super();
}
static async getInstance() {
if (!HashedTripsClass._instance) {
const instance = new HashedTripsClass();
await instance.connect();
HashedTripsClass._instance = instance;
}
return HashedTripsClass._instance;
}
getCollectionIndexes() {
return [
{ background: true, key: { agency_id: 1 } },
{ background: true, key: { line_id: 1 } },
];
}
getCollectionName() {
return 'hashed_trips';
}
getEnvName() {
return 'TML_INTERFACE_HASHED_TRIPS';
}
}
/* * */
export const hashedTrips = AsyncSingletonProxy(HashedTripsClass);