From 7481ac354c0003e1c52fcf7bf6babce928ae5f6e Mon Sep 17 00:00:00 2001 From: Marc Grabanski Date: Sat, 8 Dec 2018 20:35:34 -0600 Subject: [PATCH 1/5] Reorder README --- README.md | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 60d16a8..99b0b00 100644 --- a/README.md +++ b/README.md @@ -18,15 +18,8 @@ ## Course Thanks for taking the Intro 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. -## Excercises -Note: To handle the error "MongoError: E11000 duplicate key error collection" by dropping the database -```bash -mongo -use dbName; -db.dropDatabase(); -exit -``` -(dbName is the name of the database) + +## Exercises ### Installing MongoDB There are many ways to install MongoDB. [The offical website](https://www.mongodb.com/download-center#community) 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. @@ -38,6 +31,7 @@ Note: If you have an error like "data directory not found" or "permission denied sudo mkdir /data/db sudo chown -R $USER /data/db ``` + ### Models * location - `exercises/models` * commands @@ -51,6 +45,7 @@ This exercise will have you create connection logic and mongoose schemas. Using - [ ] 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 @@ -64,6 +59,7 @@ This exercise will have you add relationships between models. You'll then use th - [ ] 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 @@ -79,6 +75,7 @@ In this exercise, you'll learn how to use schema middleware and virtuals. Also, - [ ] 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 @@ -93,4 +90,14 @@ In this exercise, you'll have to create queries in Expressjs controllers to sati - [ ] 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. + +```bash +mongo +use dbName; +db.dropDatabase(); +exit +``` +(dbName is the name of the database) From 03f5b07af01e03f0ecc41735056dde45ce2893a2 Mon Sep 17 00:00:00 2001 From: Marc Grabanski Date: Sat, 8 Dec 2018 20:36:29 -0600 Subject: [PATCH 2/5] Add course link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 99b0b00..3c9c17a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ * [mLab](https://mlab.com/) ## Course -Thanks for taking the Intro 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. +Thanks for taking the [Introduction to MongoDB course](https://frontendmasters.com/courses/mongodb/), 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 From 4a2111bd6819f93fe717c82d83f4ccb3d27391be Mon Sep 17 00:00:00 2001 From: "Dr. Rich Cordero" Date: Wed, 12 Dec 2018 09:25:59 -0500 Subject: [PATCH 3/5] update readme add `-p` flag to `sudo mkdir /data/db` (line 31) command to avoid `mkdir: canot create director '/data/db': no such file or directory` error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c9c17a..f4befa9 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ mkdir -p /data/db ``` Note: If you have an error like "data directory not found" or "permission denied" while installing MongoDB: ```bash -sudo mkdir /data/db +sudo mkdir -p /data/db sudo chown -R $USER /data/db ``` From 0bce58aa58314893ccf2d614c8902ed5f873fdb5 Mon Sep 17 00:00:00 2001 From: young-gratia Date: Wed, 13 Feb 2019 14:59:10 +0900 Subject: [PATCH 4/5] Fix typos in exercise/queries --- exercises/queries/__test__/queries.spec.js | 16 ++++++++-------- exercises/queries/post.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/exercises/queries/__test__/queries.spec.js b/exercises/queries/__test__/queries.spec.js index c666f5b..5860f27 100644 --- a/exercises/queries/__test__/queries.spec.js +++ b/exercises/queries/__test__/queries.spec.js @@ -9,7 +9,7 @@ const { const Post = require('../post') const Author = require('../author') const mongoose = require('mongoose') -const createConent = (length, fill = 'b') => new Array(length).fill(fill).join('') +const createContent = (length, fill = 'b') => new Array(length).fill(fill).join('') describe('queries', () => { describe('postByTitle', () => { @@ -18,7 +18,7 @@ describe('queries', () => { const post = await Post.create({ title, author: mongoose.Types.ObjectId(), - content: createConent(50), + content: createContent(50), contentLength: 50 }) @@ -33,7 +33,7 @@ describe('queries', () => { const post = await Post.create({ author, title: 'Carter v', - content: createConent(50), + content: createContent(50), contentLength: 50 }) const [match] = await postsForAuthor(author) @@ -48,7 +48,7 @@ describe('queries', () => { const posts = await Post.create([ {title: 'Super Duper', author, content: createConent(1000), contentLength: 1000}, {title: 'Amazing', author, content: createConent(100), contentLength: 100}, - {title: 'Other', author, content: createConent(800), contentLength: 800} + {title: 'Other', author, content: createContent(800), contentLength: 800} ]) const matches = await postByContentLength(1000, 100) @@ -67,12 +67,12 @@ describe('queries', () => { content: createConent(1000), contentLength: 1000 }) - const post2 = await Post.create({ + const post2 = await Post.creatte({ author: author.id, title: 'Post 2', content: createConent(100), contentLength: 100, - simularPosts: [post.id] + similarPosts: [post.id] }) const match = await fullPostById(post2.id) @@ -85,7 +85,7 @@ describe('queries', () => { await Post.create([ {title: 'learn things', content: createConent(100), contentLength: 100, author}, {title: 'lean more things', content: createConent(100), contentLength: 100, author}, - {title: 'lean more things++', content: createConent(100), contentLength: 100, author} + {title: 'lean more things++', content: createContent(100), contentLength: 100, author} ]) const matches = await allPostsSlim({title: 1, content: 1}) @@ -103,7 +103,7 @@ describe('queries', () => { const post = await Post.create({ author, title: 'Post', - content: createConent(100), + content: createContent(100), contentLength: 100, similarPosts: [mongoose.Types.ObjectId()] }) diff --git a/exercises/queries/post.js b/exercises/queries/post.js index 4d55f87..f2975fc 100644 --- a/exercises/queries/post.js +++ b/exercises/queries/post.js @@ -23,7 +23,7 @@ const postSchema = new mongoose.Schema({ }, isFeatured: { type: Boolean, - deafult: false + default: false }, similarPosts: [{ type: mongoose.Schema.Types.ObjectId, From ac7bdd7b9c95443d376ea1d38286322243541289 Mon Sep 17 00:00:00 2001 From: young-gratia Date: Wed, 13 Feb 2019 15:24:41 +0900 Subject: [PATCH 5/5] Fix typo in queries.spec.js --- exercises/queries/__test__/queries.spec.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/exercises/queries/__test__/queries.spec.js b/exercises/queries/__test__/queries.spec.js index 5860f27..679b1ab 100644 --- a/exercises/queries/__test__/queries.spec.js +++ b/exercises/queries/__test__/queries.spec.js @@ -46,8 +46,8 @@ describe('queries', () => { const author = mongoose.Types.ObjectId() const posts = await Post.create([ - {title: 'Super Duper', author, content: createConent(1000), contentLength: 1000}, - {title: 'Amazing', author, content: createConent(100), contentLength: 100}, + {title: 'Super Duper', author, content: createContent(1000), contentLength: 1000}, + {title: 'Amazing', author, content: createContent(100), contentLength: 100}, {title: 'Other', author, content: createContent(800), contentLength: 800} ]) @@ -64,13 +64,13 @@ describe('queries', () => { const post = await Post.create({ title: 'Super Duper', author: author.id, - content: createConent(1000), + content: createContent(1000), contentLength: 1000 }) - const post2 = await Post.creatte({ + const post2 = await Post.create({ author: author.id, title: 'Post 2', - content: createConent(100), + content: createContent(100), contentLength: 100, similarPosts: [post.id] }) @@ -83,8 +83,8 @@ describe('queries', () => { test('only selects fields given', async () => { const author = mongoose.Types.ObjectId() await Post.create([ - {title: 'learn things', content: createConent(100), contentLength: 100, author}, - {title: 'lean more things', content: createConent(100), contentLength: 100, author}, + {title: 'learn things', content: createContent(100), contentLength: 100, author}, + {title: 'lean more things', content: createContent(100), contentLength: 100, author}, {title: 'lean more things++', content: createContent(100), contentLength: 100, author} ]) @@ -98,7 +98,7 @@ describe('queries', () => { }) }) describe('addRelatedPosts', () => { - test('should not overrided related posts that are there', async () => { + test('should not override related posts that are there', async () => { const author = mongoose.Types.ObjectId() const post = await Post.create({ author,