• Stars
    star
    181
  • Rank 212,110 (Top 5 %)
  • Language
    JavaScript
  • Created about 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[Course] Introduction to MongoDB code

Intro to MongoDB

Scott Moss & Frontend Masters

Resources

Course

Thanks for taking the Introduction to MongoDB course, created by Scott Moss & Frontend Masters. This course aims to cover a wide intro into using MongoDb with Nodejs. Topics refrain from going deep, but instead, focus on a wide view.

Exercises

Installing MongoDB

There are many ways to install MongoDB. The offical website has you covered either way. After installation, you might have to add a dbPath, a location where mongodb saves your data. You can do so like this.

mkdir -p /data/db

Note: If you have an error like "data directory not found" or "permission denied" while installing MongoDB:

sudo mkdir -p /data/db
sudo chown -R $USER /data/db

Models

  • location - exercises/models
  • commands
    • test - yarn test exercises/models/__test__/ or npm test exercises/models/__test__/

This exercise will have you create connection logic and mongoose schemas. Using the schema, you must create some CRUD functionality.

  • check out to the start branch
  • install node modules with npm or yarn
  • check the README on how to run test
  • create connection logic on connect.js
  • finish the user schema so that the the user model tests pass
  • complete the crud functions with the user model and get all the crud test to pass

Queries

  • location - exercises/queries
  • commands
    • test - yarn test exercises/queries/__test__/ or npm test exercises/queries/__test__/

This exercise will have you add relationships between models. You'll then use those models to create slightly more advanced queries than the last exercise

  • check out to the start branch
  • check the README on how to run your test
  • the post model should have have a one-to-one author field that points to the author collection
  • the post model should have a one-to-many similarPost field that points to posts
  • get all the post model tests to pass
  • get all the query tests to pass

Hooks

  • location - exercises/hooks
  • commands
    • test - yarn test exercises/hooks/__test__/ or npm test exercises/hooks/__test__/

In this exercise, you'll learn how to use schema middleware and virtuals. Also, you'll dig into indexes in more detail and create compound indexes.

  • check out to the start branch
  • check the README on how to run your test
  • add a compound index to the project schema so that project names are unique per org
  • add a virtual getter to the project schema called budgetLeft that calculates how much budget is left vs how much is spent so far
  • add a post remove hook to the org schema that removes all projects associated with the org
  • add a virtual getter to the org schema called avatar that creates the fill url to the org avatar by concatinating the cdnUrl with the org id
  • get all org tests to pass
  • get all project tests to pass

App

  • location - exercises/app
  • commands
    • start the server - node exercises/app/index.js

In this exercise, you'll have to create queries in Expressjs controllers to satisfy the request. You'll learn how to use mongodb in an API environment. You'll also have the couse to use a hosted MongoDB.

  • check out to the start branch
  • check the README on how to run your server
  • create db query for GET /todo/:id
  • create db query for GET /todo
  • create db mutation for POST /todo/
  • optional create a mLab sandbox and use your hosted DB

Debugging

Note: To handle the error MongoError: E11000 duplicate key error collection drop the database.

mongo
use dbName;
db.dropDatabase();
exit

(dbName is the name of the database)

More Repositories

1

front-end-handbook-2018

2018 edition of our front-end development handbook
HTML
4,187
star
2

front-end-handbook-2019

[Book] 2019 edition of our front-end development handbook
HTML
4,107
star
3

front-end-handbook-2017

2017 edition of our front-end development guide
HTML
3,824
star
4

front-end-handbook

The resources and tools for learning about the practice of front-end development.
HTML
1,799
star
5

front-end-handbook-2024

A guide to modern front-end web development / engineering.
HTML
1,182
star
6

learning-roadmap

The Front-End Developer Learning Roadmap by Frontend Masters
HTML
1,014
star
7

bootcamp

Frontend Masters Bootcamp
HTML
701
star
8

api-design-node-v3

[Course] API design in Node with Express v3
JavaScript
696
star
9

react-enlightenment

A thoughtful and complete introduction to React.
HTML
429
star
10

intro-node-js

[Course] Code for Introduction to Node.js
JavaScript
372
star
11

fullstack-graphql

JavaScript
370
star
12

fmmn

frontend masters minneapolis workshop notes
JavaScript
369
star
13

javascript-enlightenment

[Book] JavaScript (ES2015+) Enlightenment
HTML
308
star
14

api-design-node

[Course] API Design in Node.js code
JavaScript
256
star
15

remix-fundamentals

Remix enables you to build fantastic user experiences for the web and feel happy with the code that got you there. Get a jumpstart on Remix with this workshop.
TypeScript
255
star
16

gatsby-intro

Code for the Introduction to Gatsby course.
JavaScript
253
star
17

api-design-node-v2

[Course] API Design in Node.js, v2: REST & GraphQL code
JavaScript
232
star
18

intro-to-graphql

[Course] Introduction to GraphQL
JavaScript
191
star
19

advanced-remix

Remix enables you to build fantastic user experiences for the web and feel happy with the code that got you there. In this workshop, we'll look at some more advanced use cases when building Remix applications.
TypeScript
186
star
20

2015-02-13-React

[Course] Code for the 2015 React.js workshop with Ryan Florence
JavaScript
170
star
21

grid-flexbox-v2

Version 2 of the Flexbox and Grid course at Frontend Masters.
CSS
152
star
22

hardcore-functional-js-v2

Code for the Hardcore Functional JavaScript, v2 course
JavaScript
142
star
23

service-workers-offline

Code for the Service Workers / PWA section of the Service Workers & Offline course by Kyle Simpson
JavaScript
138
star
24

pure-react-state-management

Pure React State Management course documentation
134
star
25

serverless-with-aws

[Course] Serverless with AWS: Get a quick start into the world of Serverless functions with AWS Lambda.
JavaScript
134
star
26

fm-snippets

Code snippets for course annotations.
JavaScript
119
star
27

advanced-graphql

[Course] Advanced GraphQL - Learn advanced practices and techniques when when building a GraphQL API.
JavaScript
111
star
28

advanced-gql-v2

Code for the Advanced GraphQL Course on Frontend Masters
JavaScript
108
star
29

fm-transcripts

Transcripts of Frontend Masters Courses
91
star
30

ai-nodejs

JavaScript
85
star
31

react-state-management

64
star
32

hardcore-functional-architecture

JavaScript
57
star
33

angular-components

[Course] Code for the AngularJS 1.x Components & ES6 Course
JavaScript
57
star
34

react-web-starter

[Course] starter for react web app
JavaScript
53
star
35

ember-octane

Mike North's Ember Octane workshop
JavaScript
39
star
36

react-native-todo

[Course] Todo app for the React Native Course
Objective-C
32
star
37

ember-github-ui

[Course] Code for the Ember 2.x Course on Frontend Masters
JavaScript
28
star
38

getting-a-job-v3

Watch the course on Frontend Masters
28
star
39

sweat-book

[Course] Work out demo app for the React Native Course
26
star
40

observablish-values

JavaScript
25
star
41

web-workers

Code for the Web Workers section of the Service Workers course by Kyle Simpson
JavaScript
16
star
42

ember-commently

[Course] Code for the Comment.ly Ember.js app for the Advanced Ember 2.x course
CSS
12
star
43

ios-issues

Repository for managing publicly reported issues with the Frontend Masters iOS App
10
star
44

android-issues

Repository for managing publicly reported issues with the Frontend Masters Android App
6
star
45

fullstack-app-next-starter

TypeScript
5
star
46

blazingly-fast-js

JavaScript
5
star
47

javascript-fundamentals-v3

JavaScript
3
star
48

fem-htmx

JavaScript
2
star
49

gitbook-plugin-open-graph

Adds open graph and twitter share meta tags to gitbook
HTML
1
star
50

cielo24_php

[ARCHIVED] A PHP client library for the cielo24.com API
PHP
1
star