Closed luneice closed 4 years ago
依赖环境如下
package.json "dependencies": { "egg": "^2.15.1", "egg-mongo-native": "^3.5.0", "egg-scripts": "^2.11.0" }
配置选项如下
plugin.js exports.mongo = { enable: true, package: 'egg-mongo-native', }; config.default.js exports.mongo = { client: { host: 'localhost', port: '27017', name: 'example', }, };
无法创建 mongo 数据库连接对象,然后导致 find 方法不是函数。调试时,mongo 数据类型为 object 不是 MongoDB 类型。
请问,问题出在哪里了?
问题找到了,依赖中缺少 "mongodb": "^3.1.10" 导致 mongo 对象无法生成。
"mongodb": "^3.1.10"
mongodb 是 egg-mongo-native 的依赖,不应该需要手动添加。
依赖环境如下
配置选项如下
无法创建 mongo 数据库连接对象,然后导致 find 方法不是函数。调试时,mongo 数据类型为 object 不是 MongoDB 类型。
请问,问题出在哪里了?