嘿:]尝试通过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;
}
});
});
Remember-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>
感谢您的帮助!
最佳答案
试试这个希望它能起作用
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);