Skip to content

connect to mongoose#55

Merged
plarocque4 merged 2 commits intodevfrom
mongoose
Mar 15, 2023
Merged

connect to mongoose#55
plarocque4 merged 2 commits intodevfrom
mongoose

Conversation

@KeeyanGhoreshi
Copy link
Copy Markdown
Contributor

@KeeyanGhoreshi KeeyanGhoreshi commented Feb 20, 2023

Describe your changes

This introduces mongoose as the connection default. Though the code is relatively simple, moving forward we'll need to make some big changes to the way the app saves things to the database. Of note:

Removing Tingo
If we use mongoose then Tingo won't be relevant anymore, unless we want to use Tungus to make Tingo compatible with mongoose. Removal would be a relatively simple change. I'm not sure how much trouble it would be to use Tungus.

Restructuring the Globals
Right now to maintain the code as it is, I've had mongoose produce a MongoClient and pass it back so that the Globals have access to a database object exactly like before. The only difference in this PR is that instead of using Mongo functions directly, they're being used through mongoose. To use mongoose, we will no longer need the Globals database variables (Globals.databaseClient isn't even used anyway), instead mongoose can be accessed globally by importing it into any module that needs it.

Using Mongoose
Basically everything that utilizes the database will have to be modified to make use of the schema/model structure of mongoose. Then the functions that access the database will need to be changed to access through the models.

Issue ticket number and Jira link

REMS-338

Checklist before requesting a review

  • I have performed a self-review of my code
  • Ensure the target / base branch for any feature PR is set to dev not main (the only exception to this is releases from dev and hotfix branches)

Checklist for conducting a review

  • Review the code changes and make sure they all make sense and are necessary.
  • Pull the PR branch locally and test by running through workflow and making sure everything works as it is supposed to.

Workflow

Owner of the Pull Request will be responsible for merge after all requirements are met, including approval from at least one reviewer. Additional changes made after a review will dismiss any approvals and require re-review of the additional updates. Auto merging can be enabled below if additional changes are likely not to be needed. The bot will auto assign reviewers to your Pull Request for you.

@KeeyanGhoreshi KeeyanGhoreshi changed the base branch from main to dev February 20, 2023 18:28
Comment thread mongo-init.js
Comment thread env.json
Comment thread src/lib/MongoDatabase.ts
Comment thread src/lib/MongoDatabase.ts Outdated
this.client = new mongoDB.MongoClient(this.location);
this.database = this.client.db(this.db_name);
return resolve(this.client.connect());
const dbString = `${this.location}/${this.db_name}`
Copy link
Copy Markdown
Collaborator

@smalho01 smalho01 Feb 21, 2023

Choose a reason for hiding this comment

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

fix linting comment

Copy link
Copy Markdown
Contributor

@plarocque4 plarocque4 left a comment

Choose a reason for hiding this comment

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

Looks good.

@plarocque4 plarocque4 merged commit 99599f0 into dev Mar 15, 2023
@plarocque4 plarocque4 deleted the mongoose branch March 15, 2023 20:40
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.

4 participants