我正在尝试测试我的注册系统,以检查我的数据库中是否存在具有相同用户名的相似用户。它给出以下错误:ReferenceError: User is not defined at /Users/name/Desktop/register_system/routes/users.js:44:9
} else {
//Registration successful
User.findOne({ username: username})
.then(user => {
if(user) {
//If username already exists
errors.push({ msg: 'Username already exists!' });
res.render('register', {
errors,
username,
email,
password,
password2
});
}
});
}
不确定为什么会这样,我已经定义了User?