The next overly ambitious technical project, and a good exercise at migrations & code refactoring.
Strategy
For each major DB entity:
Create a xxx.repository.ts to be used exclusively as a DAO layer
Migrate all Bookshelf/Knex queries from the service layer down to the repository
Migrate all model.save() and model.destroy() calls down to the repository
Make the matching TypeORM entity class implement a fromBookshelfModel() to convert a TypeORM entity to Bookshelf, be careful about how relations are mapped
Update the repository API to only expose entity classes instead of Bookshelf models. Migrate all impacted classes. Bookshelf-style API (.get() etc.) can be left as is for now.
This opens things up for a migration towards either TypeORM, Knex or whatever since we'll then be using plain TS classes.
The next overly ambitious technical project, and a good exercise at migrations & code refactoring.
Strategy
For each major DB entity:
xxx.repository.ts
to be used exclusively as a DAO layerfromBookshelfModel()
to convert a TypeORM entity to Bookshelf, be careful about how relations are mapped.get()
etc.) can be left as is for now.This opens things up for a migration towards either TypeORM, Knex or whatever since we'll then be using plain TS classes.
Progress
(number is line count)