Learning basics of MongoDB and how to use it with Javascript
- Fork this repository then clone it on your computer
- Create an account on Mongo Atlas (sign-up)
- Create a database and save its credentials for later
β Commit your changes after each instruction, following the commit message format:
feat(1): Initiate NPM Project
- In this directory, initiate an NPM project
npm init
- Create a file named
import-data.js - Add NPM packages
mongooseanddotenvMongoose is a package making mongo request easier and more secure
npm install --save mongoose npm install --save dotenv
- Put your database credentials in a file named
.envlike:MONGO_URI=mongodb://username:password@host:port/database
- In the file
import-data.js, create Mongoose modelLocations- Define a mongoose schema that accepts the following entity (look at the documentation):
{ "filmType": "Long m\u00e9trage", "filmProducerName": "MANDARIN PRODUCTION", "endDate": "2020-08-21", "filmName": "TOUT S'EST BIEN PASSE", "district": "75013", "geolocation": { "coordinates": [ 2.348314535961912, 48.83566000015182 ], "type": "Point" }, "sourceLocationId": "2020-404", "filmDirectorName": "Francois OZON", "address": "rue pascal, 75013 paris", "startDate": "2020-08-20", "year": "2020", } - Validate your schema with your professor
- Create the model
Locationsusing the schema
- Define a mongoose schema that accepts the following entity (look at the documentation):
- Connect to the database, using credentials stored in the
.envfile and thedotenvpackage - Write a function that takes an array of FilmingLocations (file
lieux-de-tournage-a-paris.jsonfrom workshop 1) and imports each FilmingLocation in Mongo - Call the function with data from
lieux-de-tournage-a-paris.json, populate the database - Write a function to query one
Locationby its ID - Write a function to query all
Locationsfor a givenfilmName - Write a function to delete a
Locationby its ID - Write a function to add a
Location - Write a function to update a
Location