Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Latest commit

 

History

History
127 lines (91 loc) · 5.93 KB

week-4.md

File metadata and controls

127 lines (91 loc) · 5.93 KB

Week 4

An SSL error has occurred and a secure connection to the server cannot be made.

William Shakespeare

qw3rtman/git-fire by @qw3rtman.

Table of Contents

Slides

Theory

Before you start you'll probably want to read a bit about Databases, JSON, and MongoDB. We'll cover this in the lecture but make sure you fully understand these concept, the resources below can help.

Playground

You can do these exercises before you start working on the assignments to get comfortable with the topics covered in class. The below are interactive self guided lesson modules from freeCodeCamp. If you feel a bit more adventurous you can try the NodeSchool workshoppers.

Assignments

Storage

Storage banner

Store user input in a MongoDB database instead of the server.

Synopsis

  • Time: 8:00h
  • Goals: subgoal 7, subgoal 8
  • Due: before week 5

Description

A database will permanently store the data for you. A database is for persistence, store information apart from the server. Text is the easiest thing to store, media such as images, blobs or passwords require additional effort.

Remember that in the previous assignment you've set-up a database connection with Atlas. Now we are going to connect the server (node.js) to the database.

1. Connecting to the URI of your database
2. Save data to the database
3. Query the database from the server
4. Display data from the server to the client
5. Updating data to the database

Then start storing the user input for your matching application in the database!

  1. Do some data modelling. Think about how you are going to store the data. Every piece of data needs a type. e.g.
    • Likes can be stored as true or false
    • Are telephone numbers typeof number or are they strings?
    • Do you need seperate keys and values for firstname and lastname?
  2. Draw the structure of your database. Include that diagram in your readme.md to explains what the structure is like. (Hint: use Google Drawings or Excalidraw).
  3. To test out if your database is connected properly you can first try to add some data manually using MongoDB compass and use Find to display that data in your application.
  4. Then Use MongoDB CRUD operations to further interface with the database.
    1. Use Find to read data from the collection
    2. Use Insert to add data to collections
    3. Use Update to change data from the collection

💡In lots of online tutorials and video's you'll see people use mongoose to connect to their database and perform crud operations. We don't think that's the best way to get started so we highly suggest you don't use mongoose when you are starting out. It's too much ✨ magic and you'll also need to learn about things like schema's. Only if you think you actually need it and can explain why it's useful for your project you'll want to consider it for your project.

Remember that to pass A1 (assessment) a user needs to be able to insert or update the data in the database trough the interface. A find is not enough.

Tips

  • Start small. Don't try to store everything into the database at once.
  • You can use the mongodb package inside node to interface with your database.
  • You can use a MongoDB GUI to see and manipulate your data with a handy User Inerface.

Hand-in

  1. Push your changes:
    Commit your progess in your repository on GitHub under your username in your own matching-app repository.

  2. Create an issue:
    Mark this assignment as complete by opening an issue on our GitHub issue tracker. Fill in the issue template of week-4.md with the correct information. Include what progress you made in the description of the issue.

  3. Feedback:
    Let us know what you thought of the homework, what part you spend a lot of time on and give us any feedback. Your assignment will be reviewed by teachers and student assistants, so expect people to read it and be ready for tips and tops!