Menu Expand Search
CS4530, Summer 2025

Mongoose Attack

In this activity, you’ll work with asynchronous programming with the Mongoose library, which allows your programs to connect to a MongoDB database.

Overview

The code for this implements a part of the TranscriptService we’ve seen previously in lecture, but using a MongoDB database to store information.

Getting started

Download the starter code and run npm install. Then run npm run test; there will be a lot of test failures. The tests fail because getTranscript doesn’t return the correct result, and because addGrade isn’t fully implemented. Your first task will be understanding the difference between what getTranscript should be returning and what it’s actually returning.

Fixing the tests

To complete the task, you’ll need to learn about how Mongoose models work a bit. There are multiple ways to work through this assignment, but the one that matches the structure of the strategy.town Mongoose models uses the .populate() and .select() methods to .

Don’t worry about getting every last one of the tests perfect — the intent of this activity is to practice rapidly trying to absorb new docs while working with a group, and to give you a little bit of exposure to Mongoose models before you have to work with them in IP2. You’ll submit src/service.ts on Gradescope.