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.21 kB
/* * */ import { MongoCollectionClass } from '../../common/mongo-collection.js'; import { CreateLineSchema, UpdateLineSchema } from '@tmlmobilidade/types'; import { asyncSingletonProxy } from '@tmlmobilidade/utils'; /* * */ class LinesClass extends MongoCollectionClass { static _instance; createSchema = CreateLineSchema; updateSchema = UpdateLineSchema; constructor() { super(); } static async getInstance() { if (!LinesClass._instance) { const instance = new LinesClass(); await instance.connect(); LinesClass._instance = instance; } return LinesClass._instance; } /** * Finds Line 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_id: { $in: ids } }).toArray(); } getCollectionIndexes() { return []; } getCollectionName() { return 'lines'; } getEnvName() { return 'DATABASE_URI'; } } /* * */ export const lines = asyncSingletonProxy(LinesClass);