Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BaseRepository<MongooseDocumentOfDto, Dto>

Type parameters

  • MongooseDocumentOfDto: IBaseEntity & Dto

  • Dto: BaseEntity<Dto>

Hierarchy

Index

Constructors

constructor

  • new BaseRepository(model: Model<MongooseDocumentOfDto>, collectionName: string): BaseRepository
  • Initialize the base repository

    Parameters

    • model: Model<MongooseDocumentOfDto>

      The mongoose model for this repository

    • collectionName: string

      The collection name, used also as controller route name

    Returns BaseRepository

Properties

collectionName

collectionName: string

The collection name, used also as controller route name

Protected model

model: Model<MongooseDocumentOfDto>

The mongoose model for this repository

Methods

create

  • create(item: Dto): Promise<MongooseDocumentOfDto>

delete

  • delete(id: string): Promise<boolean>

find

  • find(query?: RepositoryQuery<Dto>): DocumentQuery<MongooseDocumentOfDto[], MongooseDocumentOfDto>

findOne

get

  • get(id: string): Promise<MongooseDocumentOfDto>
  • Return the item with specified id if exists, null otherwise.

    Parameters

    • id: string

      The item identifier (id property of [[BaseEntity]])

    Returns Promise<MongooseDocumentOfDto>

Private getObjectId

  • getObjectId(objectId: string): ObjectID

partialUpdate

  • partialUpdate(id: string, item: Partial<Dto>): Promise<MongooseDocumentOfDto>
  • Update only the specified property of the item

    Parameters

    • id: string
    • item: Partial<Dto>

      The item to update

    Returns Promise<MongooseDocumentOfDto>

update

  • update(item: Dto): Promise<MongooseDocumentOfDto>

Generated using TypeDoc