通过猫鼬连接到数据库时出现问题.
当我使用这段代码
var mongoose = require('mongoose').Mongoose;
var db = mongoose.connect('mongodb://localhost/goaljuice');
然后我有问题.
这是我的问题
TypeError: Object function Mongoose() {
this.connections = [];
this.plugins = [];
this.models = {};
this.modelSchemas = {};
this.options = {};
this.createConnection(); // default connection
} has no method 'connect'
==================================
这是我的结构文件夹:
-express_example
--app.js
--node_modules
------express, jade, mongodb, mongooses, stylus
--public
--router
--views
解决方法:
代替
var mongoose = require('mongoose').Mongoose;
尝试
var mongoose = require('mongoose');