Skip to content

Institution DAO Mongoose migration - #97

Open
AustinSMueller wants to merge 2 commits into
prisma-to-mongoose-migrationfrom
mongoose-institution
Open

Institution DAO Mongoose migration#97
AustinSMueller wants to merge 2 commits into
prisma-to-mongoose-migrationfrom
mongoose-institution

Conversation

@AustinSMueller

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the Institution data-access layer from the previous collection/Prisma-style approach to a Mongoose-backed DAO, updating the Institution service wiring and adding focused DAO unit tests to validate the new behavior.

Changes:

  • Refactors InstitutionDAO to extend MongooseGenericDAO, adds findByCaseInsensitiveName, and updates listInstitution to use Mongoose aggregation.
  • Updates InstitutionService and GraphQL router wiring to instantiate the DAO/service without passing a raw collection, and adjusts service unit tests accordingly.
  • Adds a new Mongoose Institution model and introduces DAO-level tests for pagination/aggregation and lookup helpers.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/backend/test/services/institution.service.test.js Updates service tests to mock new DAO methods (findById, update, findAll, etc.) and new constructor signature.
apps/backend/test/dao/dao.institution.test.js Adds unit tests for the new Mongoose-backed InstitutionDAO behavior and pipelines.
apps/backend/services/institution-service.js Refactors service to use Mongoose DAO methods, removes direct collection usage, and updates bulk insert logic.
apps/backend/services/application.js Updates InstitutionDAO query syntax to Mongo-style $in for findMany.
apps/backend/routers/graphql-router.js Removes institutionCollection construction and instantiates InstitutionService with authorization service only.
apps/backend/mongoose/models/institution.js Adds a Mongoose schema/model for institutions with string _id and expected fields.
apps/backend/dao/institution.js Migrates DAO implementation to MongooseGenericDAO and adds case-insensitive name lookup helper.
Comments suppressed due to low confidence (1)

apps/backend/services/institution-service.js:162

  • Same issue as above: the second argument to Error is ignored, so trimmedName is never reflected in the thrown error. Remove the unused argument to avoid confusion.
            const existingInstitution = await this.institutionDAO.findByCaseInsensitiveName(trimmedName);
            const isDuplicate = (existingInstitution) && existingInstitution?._id !== institutionID
            if (isDuplicate) {
                throw new Error(ERROR.DUPLICATE_INSTITUTION_NAME, trimmedName);
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/backend/services/institution-service.js
Comment thread apps/backend/services/institution-service.js Outdated
Comment thread apps/backend/dao/institution.js
@AustinSMueller
AustinSMueller requested a review from n2iw July 30, 2026 16:44
@AustinSMueller
AustinSMueller marked this pull request as ready for review July 30, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants