@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.
42 lines (41 loc) • 1.42 kB
JavaScript
/* * */
import { MongoCollectionClass } from '../../common/mongo-collection.js';
import { CreateSamSchema, UpdateSamSchema } from '@tmlmobilidade/types';
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
/* * */
class SamsClass extends MongoCollectionClass {
static _instance;
createSchema = CreateSamSchema;
updateSchema = UpdateSamSchema;
constructor() {
super();
}
static async getInstance() {
if (!SamsClass._instance) {
const instance = new SamsClass();
await instance.connect();
SamsClass._instance = instance;
}
return SamsClass._instance;
}
getCollectionIndexes() {
return [
{ background: true, key: { created_at: 1 } },
{ background: true, key: { agency_id: 1 } },
{ background: true, key: { agency_id: 1, created_at: -1 } },
{ background: true, key: { latest_apex_version: 1 } },
{ background: true, key: { created_at: -1, latest_apex_version: 1 } },
{ background: true, key: { mac_sam_serial_number: 1 } },
{ background: true, key: { seen_first_at: 1 } },
{ background: true, key: { seen_last_at: 1 } },
];
}
getCollectionName() {
return 'sams';
}
getEnvName() {
return 'DATABASE_URI';
}
}
/* * */
export const sams = asyncSingletonProxy(SamsClass);