@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.
35 lines (34 loc) • 991 B
JavaScript
/* * */
import { MongoCollectionClass } from '../../common/mongo-collection.js';
import { CreateVehicleSchema, UpdateVehicleSchema } from '@tmlmobilidade/types';
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
/* * */
class VehiclesClass extends MongoCollectionClass {
static _instance;
createSchema = CreateVehicleSchema;
updateSchema = UpdateVehicleSchema;
constructor() {
super();
}
static async getInstance() {
if (!VehiclesClass._instance) {
const instance = new VehiclesClass();
await instance.connect();
VehiclesClass._instance = instance;
}
return VehiclesClass._instance;
}
getCollectionIndexes() {
return [
{ background: true, key: { name: 1 } },
];
}
getCollectionName() {
return 'vehicles';
}
getEnvName() {
return 'DATABASE_URI';
}
}
/* * */
export const vehicles = asyncSingletonProxy(VehiclesClass);