我正在尝试在Node.js中进行登录。但是我对如何使用数据库感到困惑。我的Login.html和database.js就像。http://scotch.io/tutorials/javascript/easy-node-authentication-setup-and-local因此,请给我适当的想法。
<form action="/login" method="post">
<div class="form-group">
<label>Email</label>
<input type="text" class="form-control" name="email">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" class="form-control" name="password">
</div>
<button type="submit" class="btn btn-warning btn-lg">Login</button>
database.js:
module.exports = {
'url' : 'your-database-here'
};
您server.js
的代码应该在其中(假设您正在遵循完全链接的教程)。
var configDB = require('./config/database.js');
mongoose.connect(configDB.url);
根据该代码,您的database.js
文件必须位于config文件夹中(而不是与相同的文件夹中server.js
)。因此,请确保您正在执行此操作。
接下来,将您的mongodb url放置在您的中database.js
。
module.exports = {
'url' : 'mongodb://<user>:<pass>@mongo.onmodulus.net:27017/Mikha4ot'
};
确保<user>
用您的用户名和<pass>
密码替换。
我会帮你。
module.exports
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句