Files
freeCodeCamp/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose.english.md
Ambar Mutha bcef08424c add comment explaining back-end challenges don't need a solution (#37111)
* add solution to a challenge

add solution to the challenge: add-a-description-to-your-package-json

* add comment to all backend challenges
The comment expllains that these challenges don't need a solution.
2019-10-24 13:38:13 +09:00

52 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 587d7fb6367417b2b2512c06
title: Install and Set Up Mongoose
challengeType: 2
forumTopicId: 301540
---
## Description
<section id='description'>
Add mongodb and mongoose to the projects package.json. Then require mongoose. Store your mLab database URI in the private <code>.env</code> file as MONGO_URI. Connect to the database using <code>mongoose.connect(&lt;Your URI&gt;)</code>
</section>
## Instructions
Add mongodb and mongoose to the projects <code>package.json</code>. Then require mongoose. Store your mLab database URI in the private <code>.env</code> file as <code>MONGO_URI</code>. Connect to the database using <code>mongoose.connect(&lt;Your URI&gt;)</code>
<section id='instructions'>
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: '"mongodb" dependency should be in package.json'
testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/file/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''mongodb''); }, xhr => { throw new Error(xhr.responseText); })'
- text: '"mongoose" dependency should be in package.json'
testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/file/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''mongoose''); }, xhr => { throw new Error(xhr.responseText); })'
- text: '"mongoose" should be connected to a database'
testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/is-mongoose-ok'').then(data => {assert.isTrue(data.isMongooseOk, ''mongoose is not connected'')}, xhr => { throw new Error(xhr.responseText); })'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
</section>
## Solution
<section id='solution'>
```js
/**
Backend challenges don't need solutions,
because they would need to be tested against a full working project.
Please check our contributing guidelines to learn more.
*/
```
</section>