Files
freeCodeCamp/curriculum/challenges/russian/05-apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose.russian.md

1.8 KiB
Raw Blame History

id, title, challengeType, forumTopicId, localeTitle
id title challengeType forumTopicId localeTitle
587d7fb6367417b2b2512c06 Install and Set Up Mongoose 2 301540 Установить и настроить Mongoose

Description

Добавьте mongodb и mongoose в пакет проекта.json. Тогда требуй мангуста. Сохраните свой URI базы данных mLab в личном файле .env как MONGO_URI. Подключитесь к базе данных, используя mongoose.connect ( )

Instructions

Add mongodb and mongoose to the projects package.json. Then require mongoose. Store your mLab database URI in the private .env file as MONGO_URI. Connect to the database using mongoose.connect(<Your URI>)

Tests

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); })