Add hints for "install and set up mongoose" (#36474)
* Add hints for "install and set up mongoose" * Add hint for how to solve the timeout error * Add hint for what to put in the `.env` file * Add code snippets for `.env`, `package.json` and `myApp.js` * Restructure hints and headers * Remove code solution from timeout hint * Restructure headers to match the new hint template * Move hint subject below the header Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Move hint subject below the header Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Update text in spoiler tag Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Update text in spoiler tag Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Update text in spoiler tag Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Add javascript tag to code block Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Move first line of code below ``` Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Remove placeholder text Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Add json tag to code block Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Remove redundant sentence Co-Authored-By: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * Format solutions section and hint * Replace tabs with 2 space indents in `package.json` * Remove the spoiler tags from each file name * Remove placeholder comments in `myApp.js` to make it easier to read the code * Update sentence in hint as two words were not displaying
This commit is contained in:
committed by
Randell Dawson
parent
3ac898b041
commit
7f3769f8e0
@ -1,7 +1,7 @@
|
||||
---
|
||||
title: Install and Set Up Mongoose
|
||||
---
|
||||
## Install and Set Up Mongoose
|
||||
# Install and Set Up Mongoose
|
||||
|
||||
You might want to check both the [MongoDB](https://www.npmjs.com/package/mongodb) and the [Mongoose](https://www.npmjs.com/package/mongoose) NPM Repositories for the manual configuration if you are not using Giltch.
|
||||
|
||||
@ -12,6 +12,96 @@ OR
|
||||
2. Once done add the MONGO_URL in .env file and save your path as
|
||||
```` mongodb://<dbuser>:<dbpassword>@ds<PORT>.mlab.com:<PORT>/<DATABASE-NAME> ```` which you copy from mLab. Remember to remove the angle brackets ````< >```` when you replace your username and password of your database.
|
||||
|
||||
## Hints
|
||||
|
||||
### Hint #1
|
||||
**Timeout error**
|
||||
|
||||
If the tests are timing out, check the `package.json` file. Ensure the final dependency does not end in a `,`.
|
||||
|
||||
For example, this will result in a timeout error:
|
||||
```
|
||||
"dependencies": {
|
||||
"express": "^4.12.4",
|
||||
"body-parser": "^1.15.2",
|
||||
},
|
||||
```
|
||||
|
||||
### Hint #2
|
||||
**add MONGO_URI to .env**
|
||||
* Insert a line that looks similar to: `MONGO_URI=mongodb+srv://<username>:<password>@<clustername>-vlas9.mongodb.net/test?retryWrites=true`. `<username>` and `<clustername>` will be automatically generated by MongoDB.
|
||||
|
||||
* Replace `<password>` with your password. There should be no `<>` characters (unless those are in your password).
|
||||
|
||||
Still having issues? Check the below hints:
|
||||
|
||||
* Remove spaces before and after `=`. This is correct: `MONGO_URI=mongodb...`. This is incorrect: `MONGO_URI = mongodb...`
|
||||
|
||||
* Do you have symbols or special characters in your password, e.g. `$&(@`? If so, you will need to translate these into unicode. MongoDB has instructions on how to do this. I would suggest changing your password to be lettes and numbers only for simplicity.
|
||||
|
||||
|
||||
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
|
||||
## Solutions
|
||||
|
||||
<details><summary>Solution #1 (Click to Show/Hide)</summary>
|
||||
|
||||
**.env**
|
||||
|
||||
```
|
||||
GLITCH_DEBUGGER=true
|
||||
# Environment Config
|
||||
|
||||
# store your secrets and config variables in here
|
||||
# only invited collaborators will be able to see your .env values
|
||||
|
||||
# reference these in your code with process.env.SECRET
|
||||
SECRET=
|
||||
MADE_WITH=
|
||||
MONGO_URI=mongodb+srv://<username>:<ENTERYOURPASSWORDHERE>@<clustername>-vlas9.mongodb.net/test?retryWrites=true
|
||||
# note: .env is a shell file so there can't be spaces around =
|
||||
```
|
||||
|
||||
**package.json**
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "fcc-mongo-mongoose-challenges",
|
||||
"version": "0.0.1",
|
||||
"description": "A boilerplate project",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node server.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.12.4",
|
||||
"body-parser": "^1.15.2",
|
||||
"mongodb": "^3.0.0",
|
||||
"mongoose": "^5.6.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.4.5"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://hyperdev.com/#!/project/welcome-project"
|
||||
},
|
||||
"keywords": [
|
||||
"node",
|
||||
"hyperdev",
|
||||
"express"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
||||
```
|
||||
|
||||
**myApp.js**
|
||||
|
||||
```javascript
|
||||
/** # MONGOOSE SETUP #
|
||||
/* ================== */
|
||||
|
||||
/** 1) Install & Set up mongoose */
|
||||
const mongoose = require('mongoose');
|
||||
mongoose.connect(process.env.MONGO_URI);
|
||||
```
|
||||
</details>
|
||||
|
||||
|
Reference in New Issue
Block a user