0.0.26 • Published 1 year ago

nest-base-structure v0.0.26

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

The code is defining an abstract class called BaseService in Typescript that serves as a base service for other services to inherit from.

This class contains several async methods that can be used by any inheriting service to perform CRUD (Create, Read, Update and Delete) operations on a database. These methods include:

  • createAndSave(dto: object): creates and saves a new entity

  • find(options?: CustomFindManyOptions<ReadModel>): Promise<{ data: ReadModel[]; skip: number; take: number; total: number } | undefined>: finds entities based on given conditions and returns an array of ReadModel objects along with paging information like skip, take and total.

  • findReport(options?: CustomFindManyOptions<ReadModel>): Promise<{ items: ReadModel[]; skip: number; take: number; total: number } | undefined>: finds entities and returns a report containing ReadModel objects along with paging information.

  • reportTotal(where?: GenericEntity<ReadModel>): Promise<{ items: object }>: returns a report containing items based on given conditions.

  • findOne(conditions?: FindConditions<ReadModel>, options?: FindOneOptions<ReadModel>): Promise<ReadModel | undefined>: finds one entity based on given conditions.

  • findById(id: number): Promise<ReadModel>: finds an entity by its id.

  • delete(criteria: ...): Promise<DeleteResult>: deletes one or multiple entities based on given criteria.

  • deleteById(id: number): Promise<DeleteResult>: deletes an entity by its id.

  • update(criteria: ..., partialEntity: QueryDeepPartialEntity<WriteModel>): Promise<UpdateResult>: updates one or multiple entities based on given criteria and a partial entity object.

  • max(dto: MaxDto): Promise<any>: returns the maximum value of a numeric field in a table.

  • softDelete(criteria: ...): Promise<UpdateResult>: soft-deletes one or multiple entities based on given criteria.

This class is essentially a generic implementation of a base service with all common CRUD operations provided. Any inheriting service can then use these methods by injecting a BaseDataAccess object that matches the data model being worked with.

0.0.26

1 year ago

0.0.25

1 year ago

0.0.24

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago