Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是不是在 egg 2.15 中使用需要用其他配置选项 #41

Closed
luneice opened this issue Jun 10, 2020 · 2 comments
Closed

是不是在 egg 2.15 中使用需要用其他配置选项 #41

luneice opened this issue Jun 10, 2020 · 2 comments

Comments

@luneice
Copy link

luneice commented Jun 10, 2020

依赖环境如下

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 类型。

请问,问题出在哪里了?

@luneice
Copy link
Author

luneice commented Jun 10, 2020

问题找到了,依赖中缺少 "mongodb": "^3.1.10" 导致 mongo 对象无法生成。

@luneice luneice closed this as completed Jun 10, 2020
@brickyang
Copy link
Owner

mongodb 是 egg-mongo-native 的依赖,不应该需要手动添加。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants