UNPKG

@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.27 kB
/* * */ import { MongoCollectionClass } from '../../common/mongo-collection.js'; import { CreateTypologySchema, UpdateTypologySchema } from '@tmlmobilidade/types'; import { asyncSingletonProxy } from '@tmlmobilidade/utils'; /* * */ class TypologiesClass extends MongoCollectionClass { static _instance; createSchema = CreateTypologySchema; updateSchema = UpdateTypologySchema; constructor() { super(); } static async getInstance() { if (!TypologiesClass._instance) { const instance = new TypologiesClass(); await instance.connect(); TypologiesClass._instance = instance; } return TypologiesClass._instance; } /** * Finds Typology documents by agency IDs. * * @param ids - The agency IDs to search for // * @returns A promise that resolves to an array of matching documents */ async findByAgencyIds(ids) { return this.mongoCollection.find({ agency_ids: { $in: ids } }).toArray(); } getCollectionIndexes() { return []; } getCollectionName() { return 'typologies'; } getEnvName() { return 'DATABASE_URI'; } } /* * */ export const typologies = asyncSingletonProxy(TypologiesClass);