Institution DAO Mongoose migration - #97
Open
AustinSMueller wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
InstitutionDAOto extendMongooseGenericDAO, addsfindByCaseInsensitiveName, and updateslistInstitutionto use Mongoose aggregation. - Updates
InstitutionServiceand GraphQL router wiring to instantiate the DAO/service without passing a raw collection, and adjusts service unit tests accordingly. - Adds a new Mongoose
Institutionmodel 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
Erroris ignored, sotrimmedNameis 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.
AustinSMueller
marked this pull request as ready for review
July 30, 2026 16:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.