[Solved] CEN3031 Assignment 3: Persisting data using MongoDB and Mongoose

30 $

SKU: [Solved] CEN3031 Assignment 3: Persisting data using MongoDB and Mongoose Category: Tag:

Our application at this point has a couple of issues:

  • our front-end Angular application does not communicate with the server we built in assignment 1
  • each time the server starts, we reload the data from the same JSON file.

It would be better if the data was stored elsewhere in a persistent fashion so that even if the server were to crash, our data would remain unharmed.

In this assignment, we will focus on persisting data by moving the JSON file to a dedicated database. In our case, we will be using MongoDB, which stores data as documents. These documents are very similar to JSON objects, making MongoDB a good candidate for our web application.


If you take a look at MongoDB’s introductory documentation, you will notice there’s quite a bit of code that has to be written to add, find, update, or delete data using their APIs. Mongoose simplifies the process of communicating with MongoDB and also provides tools to organize/model the data into schemas. Schemas are used to pre-define the data’s attributes, and the type each attribute will have. Read this tutorial that discusses how to use Mongoose with Node.js before continuing with the assignment.


MongoLab is an online service that will host your database in the cloud. While you could just run a local instance of MongoDB, registering for an account with MongoLab removes hassles surrounding installing the database on your machine. Make sure to register for an account before completing the assignment.


To port the listing data to MongoDB, you will be doing the following:

  • Defining a schema for the ‘Listing’ collection
  • Create a script that converts the JSON entries into Mongo documents and saves the documents to your database
  • Retrieve/update/delete documents through database queries


  1. Clone the repository
  2. Define your schema in ListingSchema.js
  3. Update the config.js file to include the uri to your MongoLab database.
  4. Fill out the JSONtoMongo.js script to add the listings to your database
  5. Ensure your schema passes the tests by running mocha listing.model.test.js
  6. Complete the functions in queries.js


There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CEN3031 Assignment 3: Persisting data using MongoDB and Mongoose
30 $