Git Product home page Git Product logo

lab-mongoose-recipes's Introduction

logo_ironhack_blue 7

Mongoose Recipes

Introduction

thai_style_chicken_noodle_soup_pieces_recipe_web

We learned how to use Mongoose to create Schemas and then interact with our MongoDB database. In the following exercise, we will practice how to implement this by creating awesome recipes.

Requirements

  • Fork this repo
  • Clone this repo

Submission

  • Upon completion, run the following commands:

    git add .
    git commit -m "done"
    git push origin master
    
  • Create Pull Request so your TAs can check up your work.

Instructions

Iteration 1 - Recipe Schema

The recipes.js file already connects to the recipesApp database. Now we need to create a Recipe Schema. The schema should have the following fields:

  • title. Type String. It should be required and unique.
  • level. Type String. Only can be one of the following values: Easy Peasy - Amateur Chef - UltraPro Chef (remember the ENUM ๐Ÿ˜‰)
  • ingredients. Type Array.
  • cuisine. Type String. Should be required.
  • dishType. Type String. Possible values: Breakfast - Dish - Snack - Drink - Dessert - Other.
  • image. Type String. Default value: https://images.media-allrecipes.com/images/75131.jpg.
  • duration. Type Number. Min value should be 0.
  • creator. Type String
  • created. Type Date. By default today.

Iteration 2 - Create a recipe

Using the Model.create method, you should pass the info to create a new recipe. After the creation, you can use MongoDB Shell to check everything goes ok. After inserting the recipe, you should console.log the title of the recipe.

To run your code, remember you should use $ node recipes.js.

Iteration 3 - Insert Many recipes

Form the data.js file we are importing an array of recipes. Using the Model.insertMany method, you should add the entire array to the database. After inserting the elements, print on the console the title of each recipe.

Iteration 4 - Update recipe

Now you should have six different recipes in the database, but there was a mistake in one of them. The Rigatoni alla Genovese does not take that long. You should update the duration field and set it to 100. After updating it, print a success message!

Iteration 5 - Remove a recipe

Oh oh! The Carrot Cake is no longer available, so we need to remove it from the database. Using the Model.remove method, remove that recipe from the database and display a success message after doing it!

Iteration 6 - Close the Database

After doing all the task you should close the database. Otherwise, the connection will keep open. Be careful about the asynchrony of all process; you should close it after everything is done! ๐Ÿ˜‰

Happy coding! โค๏ธ

lab-mongoose-recipes's People

Contributors

marcospalaciosiii avatar mc100s avatar papuarza avatar sandrabosk avatar tawebbcn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.