NodeJS + Express + Mongoose(MongoDB)数据库插入错误
||
我在使用NodeJS / Express / Mongoose执行以下代码时,在mongodb日志中收到错误\“ Sun Jun 12 15:27:12 SyntaxError:missing; before statement(shell):1 \”)。我没有从函数返回错误。任何指导将不胜感激。
// Launch express and server
var express = require(\'express\');
var app = express.createServer();
//connect to DB
var mongoose = require(\'mongoose\');
var db = mongoose.connect(\'mongodb://127.0.0.1/napkin_0.1\');
// Define Model
var Schema = mongoose.Schema;
var UserSchema = new Schema({
name : String,
age : String
});
mongoose.model(\'Document\', UserSchema);
var User = mongoose.model(\'Document\');
var user = new User();
user.name = \'Jim\';
user.age = \'27\';
user.save(function(err, user_Saved){
if(err){
throw err;
console.log(err);
}else{
console.log(\'saved!\');
}
});
//Launch Server
app.listen(3002);
没有找到相关结果
已邀请:
2 个回复
扫窟
玩翁文醚碱