嘿:]在尝试通过api.post('/send/remember-me', function (req, res)
发送数据后,条目在我的收藏集中重复出现,请参阅下面的
rememberMe 1 false 8.03 KB
remembermes 1 false 16.08 KB
我以这种方式做我的架构:
Remember.js
var mongoose = require('mongoose');
var rememberMeModel = mongoose.Schema({
username: {
type: String
}
});
var rememberMe = module.exports = mongoose.model('rememberMe', rememberMeModel);
index.js
var rememberMe = require('./models/Remember');
api.post('/send/remember-me', function (req, res) {
var rememberCredential = new rememberMe();
rememberCredential.username = req.body.username;
rememberCredential.save( function(err) {
if(err) {
console.log(err);
return;
}
});
});
记住-me.html
<form action="/send/remember-me" method="post">
<div class="input-field col s12 l6">
<input type="text" id="username" name="username" class="validate">
<label for="username">Username</label>
</div>
<button class="btn waves-effect waves-light" type="submit" value="Submit">Testar
<i class="material-icons right">send</i>
</button>
</form>
感谢帮助我!
答案 0 :(得分:0)
试试希望它有效
var mongoose = require('mongoose');
var rememberMeModel = mongoose.Schema({
username: {
type: String
} }); module.exports = mongoose.model('rememberMe', rememberMeModel);
而不是
var mongoose = require('mongoose');
var rememberMeModel = mongoose.Schema({
username: {
type: String
}
});
var rememberMe = module.exports = mongoose.model('rememberMe', rememberMeModel);