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.

38 lines (37 loc) 1.19 kB
/* * */ import { MongoCollectionClass } from '../../common/mongo-collection.js'; import { CreateOrganizationSchema, UpdateOrganizationSchema } from '@tmlmobilidade/types'; import { asyncSingletonProxy } from '@tmlmobilidade/utils'; /* * */ class OrganizationsClass extends MongoCollectionClass { static _instance; createSchema = CreateOrganizationSchema; updateSchema = UpdateOrganizationSchema; constructor() { super(); } static async getInstance() { if (!OrganizationsClass._instance) { const instance = new OrganizationsClass(); await instance.connect(); OrganizationsClass._instance = instance; } return OrganizationsClass._instance; } getCollectionIndexes() { return [ { background: true, key: { name: 1 }, unique: true }, ]; } getCollectionName() { return 'organizations'; } getEnvName() { return 'DATABASE_URI'; } } /** * @deprecated This class is deprecated and will be removed in the future. * Use `@tmlmobilidade/go-interfaces-go-db` instead. */ export const organizations = asyncSingletonProxy(OrganizationsClass);