Javascript 在节点js中定义模型时,架构不是构造函数

Javascript 在节点js中定义模型时,架构不是构造函数,javascript,node.js,Javascript,Node.js,我正在为书店创建应用程序 var _mongoose = require("mongoose"); var Schema = _mongoose.Schema(); var books = new Schema ({ title : { type : String}, author : { type : String}, genre : { type: String}, read : { type : Boolean, default : false} }); modu

我正在为书店创建应用程序

var  _mongoose  =  require("mongoose");
var  Schema =  _mongoose.Schema();
var  books  =  new Schema ({
 title : { type : String},
author : { type : String},
genre  : { type: String},
read  : { type : Boolean, default  : false}
});

module.exports = _mongoose.Model('Books',books);
此代码给出错误:

var  books  =  new Schema ({
           ^

TypeError: Schema is not a constructor
由于我是node js的新手,请建议如何继续

猫鼬快车版

{
"express": "^4.15.4",

"mongoose": "^4.11.12"
}
感谢

一个有效的例子:

var _mongoose  = require("mongoose");
var Books  = new _mongoose.Schema({
    title: { type: String },
    author: { type: String },
    genre: { type: String },
    read: { type: Boolean, default: false }
});

module.exports = _mongoose.model('Books', Books);
您两次调用Schema,mongoose.model都是小写的。检查文档

工作示例:

var _mongoose  = require("mongoose");
var Books  = new _mongoose.Schema({
    title: { type: String },
    author: { type: String },
    genre: { type: String },
    read: { type: Boolean, default: false }
});

module.exports = _mongoose.model('Books', Books);

您两次调用Schema,mongoose.model都是小写的。检查doc

var Schema=\u mongoose.Schema现在使用mongoose.Schema时出现错误--此。$\u0.stricmode=Schema.options&&Schema.options.strict;^TypeError:无法读取未定义的书籍=新书的属性“选项”({标题:“smth”,作者:“smth”,类型:“smth”,读取:true})@EmirMaljanovic:-它给了我编译时错误
var Schema=\u mongoose.Schema现在使用mongoose.Schema时出现错误--此。$\u0.stricmode=Schema.options&&Schema.options.strict;^TypeError:无法读取未定义的书籍=新书的属性“选项”({标题:“smth”,作者:“smth”,类型:“smth”,读取:true})@EmirMaljanovic:-它给了我编译时错误\u mongoose.model('Books',Books);这很有效。。。谢谢你的猫鼬模型(“书”,书);这很有效。。。谢谢