1.8 KiB
1.8 KiB
id, title, challengeType, isHidden, localeTitle
id | title | challengeType | isHidden | localeTitle |
---|---|---|---|---|
587d7fb6367417b2b2512c06 | Install and Set Up Mongoose | 2 | false | 安装和设置 Mongoose |
Description
require('mongoose')
,使用mongoose.connect()
命令来连接数据库。
mongoose.connect(<Your URI>, { useNewUrlParser: true, useUnifiedTopology: true });
Instructions
Tests
tests:
- text: "在 package.json 文件中应该有 'mongodb' 依赖。"
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: "在 package.json 文件中应该有 'mongoose' 依赖。"
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' 应该已经连接数据库。"
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); })'
Challenge Seed
Solution
/**
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.
*/