Skip to content

User DAO Mongoose Migration - #100

Draft
AustinSMueller wants to merge 2 commits into
prisma-to-mongoose-migrationfrom
mongoose-user
Draft

User DAO Mongoose Migration#100
AustinSMueller wants to merge 2 commits into
prisma-to-mongoose-migrationfrom
mongoose-user

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 user data access in the backend from direct/native collection usage (and prior Prisma patterns) to a Mongoose-backed UserDAO, updating service code paths and tests accordingly.

Changes:

  • Reworked UserDAO to extend a new MongooseGenericDAO using a new Mongoose User model.
  • Updated UserService (and some other services) to query via userDAO methods (findById, findFirst, findMany, update, updateMany, aggregate) and added findByID/findByIDs helpers.
  • Updated a broad set of unit tests to mock userDAO instead of userCollection / aggregation pipelines.

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
apps/backend/services/user.js Switches user operations to UserDAO + adds helper methods; updates several query/update paths.
apps/backend/dao/user.js Converts UserDAO from Prisma/collection usage to Mongoose via MongooseGenericDAO.
apps/backend/mongoose/models/user.js Adds Mongoose User schema/model aligned to existing document shape (incl. updateAt).
apps/backend/services/organization-service.js Drops native userCollection dependency; uses UserDAO for user org updates.
apps/backend/services/application.js Replaces direct user collection queries with userService.findByID/findByIDs and updates user lookups.
apps/backend/services/approved-studies.js Removes native userCollection dependency; uses UserDAO for submitter lookup.
apps/backend/services/submission.js Updates user queries to use _id-based filters with userDAO.
apps/backend/routers/graphql-router.js Updates service constructors to match new signatures (no user collection injection).
apps/backend/app.js Updates service wiring for organization/approved-studies/user services (no user collection injection).
apps/backend/test/dao/dao.user.test.js Replaces Prisma-based DAO tests with Mongoose model mock coverage for UserDAO.
apps/backend/test/graphql-queries/batch-job.test.js Adjusts UserService construction to new constructor signature.
apps/backend/test/services/user.updateUserInstitution.test.js Updates tests to mock userDAO.updateMany and new error-handling behavior.
apps/backend/test/services/user.updateUserInfo.approvedStudyStatus.test.js Updates tests to assert userDAO.update usage; adds rejection test for UPDATE_FAILED.
apps/backend/test/services/user.updateMyUser.test.js Updates test scaffolding to use userDAO.findById/update semantics.
apps/backend/test/services/user.requestAccess.test.js Uses userDAO.getUsersByNotifications mocking instead of user collection.
apps/backend/test/services/user.reopenOwner.test.js Updates UserService constructor call signature.
apps/backend/test/services/user.listUsers.test.js Replaces aggregation expectations with userDAO.findMany expectations.
apps/backend/test/services/user.listActiveDCPs.test.js Updates constructor + DAO mocking to findMany.
apps/backend/test/services/user.listActiveCurators.test.js Updates constructor + DAO mocking to findMany.
apps/backend/test/services/user.isUserPrimaryContact.test.js Updates constructor + DAO mocking to findMany.
apps/backend/test/services/user.grantToken.test.js Updates tests to assert userDAO.update usage and UPDATE_FAILED behavior.
apps/backend/test/services/user.getUsersByIDs.test.js Updates construction comments/signature for UserService.
apps/backend/test/services/user.getUser.test.js Switches from mocked implementation to real getUser bound to instance; updates mocks to userDAO.findFirst.
apps/backend/test/services/user.getFedLeads.test.js Replaces aggregation with userDAO.findMany expectations.
apps/backend/test/services/user.getDCPs.test.js Replaces aggregation with userDAO.findMany expectations.
apps/backend/test/services/user.getCollaboratorsByStudyID.test.js Replaces aggregation pipeline usage with userDAO.findMany expectations.
apps/backend/test/services/user.getAdminPBACUsers.test.js Replaces aggregation with userDAO.findMany expectations.
apps/backend/test/services/user.getAdmin.test.js Replaces aggregation with userDAO.findMany expectations.
apps/backend/test/services/user.disableInactiveUsers.test.js Updates to userDAO.updateMany returning {count} and userDAO.findMany for post-update fetch.
apps/backend/test/services/user.checkForInactiveUsers.test.js Updates aggregation execution to userDAO.aggregate instead of native collection.
apps/backend/test/services/submission.editSubmissionCollaborators.test.js Updates user lookup filter from {id: ...} to {_id: ...}.
apps/backend/test/services/data-submission.test.js Updates user lookup filter from {id: ...} to {_id: ...}.
apps/backend/test/services/organization.service.test.js Updates Organization constructor signature and asserts userDAO.updateUserOrg integration.
apps/backend/test/services/approved-studies.test.js Updates ApprovedStudiesService constructor signature (no user collection).
apps/backend/test/services/approved-studies-notification-error-handling.test.js Updates ApprovedStudiesService constructor signature (no user collection).
apps/backend/test/services/application.test.js Refactors mocked userService interface away from userCollection to findByID/findByIDs.
apps/backend/test/services/application.remindApplicationSubmission.test.js Refactors mocked userService interface away from userCollection to findByID/findByIDs.
apps/backend/test/services/application.deleteInactiveApplications.test.js Refactors mocked userService interface away from userCollection.aggregate to findByIDs.

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

Comment thread apps/backend/services/user.js Outdated
Comment thread apps/backend/services/user.js Outdated
@AustinSMueller
AustinSMueller requested a review from n2iw July 30, 2026 20:28
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