New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@tc-libs/database

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tc-libs/database

Layer base Mongo/Mongoose del monorepo.

latest
npmnpm
Version
3.9.0
Version published
Maintainers
1
Created
Source

@tc-libs/database

Layer base Mongo/Mongoose del monorepo.

Il package contiene:

  • DatabaseOptionsModule per costruire MongooseModuleOptions
  • abstract entity/repository riusabili
  • interfacce per query, sessioni, cache e pagination
  • costanti e decorator di supporto

DatabaseOptionsModule

Serve per centralizzare la costruzione della connection string Mongo:

DatabaseOptionsModule.register({
  proto: 'mongodb',
  host: '127.0.0.1:27017',
  port: 27017,
  name: 'mydb',
  user: 'mongo',
  password: 'secret',
  debug: false,
});

Poi:

MongooseModule.forRootAsync({
  imports: [DatabaseOptionsModule.register(...)],
  useExisting: DatabaseOptionsService,
});

Repository base

La classe piu importante e DatabaseMongoRepositoryAbstract<Entity, EntityDocument>.

Fornisce:

  • CRUD standard
  • join/populate opzionale
  • returnPlain
  • supporto ClientSession
  • integrazione cache con @tc-libs/app-cache
  • raw() per aggregate pipeline
  • startTransaction()

Esempio repository custom

export class UserRepository extends DatabaseMongoRepositoryAbstract<
  UserEntity,
  UserDoc
> {
  protected readonly _logger = new Logger(UserRepository.name);

  constructor(
    @InjectModel(UserEntity.name) model: Model<UserEntity>,
    @InjectConnection() connection: Connection,
    cache: AppCacheService,
  ) {
    super(model, connection, cache);
  }
}

Abstract entity

  • DatabaseBaseEntityAbstract
  • DatabaseMongoEntityAbstract

Ti evitano di ridefinire sempre _id, createdAt, updatedAt.

Interfacce piu usate

  • IDatabaseFindOneOptions
  • IDatabaseFindAllOptions
  • IDatabaseCreateOptions
  • IDatabaseManyOptions
  • IDatabaseFindOneAndUpdateOptions

Sviluppo

nx build database
nx test database

FAQs

Package last updated on 01 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts