https://github.com/well2333/nonebot-plugin-mongodb
基于 MongoDB ODM 的数据库管理插件
https://github.com/well2333/nonebot-plugin-mongodb
beanie mongodb nonebot-plugin nonebot2
Last synced: about 1 month ago
JSON representation
基于 MongoDB ODM 的数据库管理插件
- Host: GitHub
- URL: https://github.com/well2333/nonebot-plugin-mongodb
- Owner: Well2333
- License: mit
- Created: 2023-07-11T09:13:03.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-14T10:31:03.000Z (almost 2 years ago)
- Last Synced: 2024-10-18T08:54:12.832Z (7 months ago)
- Topics: beanie, mongodb, nonebot-plugin, nonebot2
- Language: Python
- Homepage:
- Size: 229 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 💿 安装
> 如果你不是插件开发者,那么此插件一般不需要额外安装和加载
pip
pip install nonebot-plugin-mongodb
pdm
pdm add nonebot-plugin-mongodb
poetry
poetry add nonebot-plugin-mongodb
conda
conda install nonebot-plugin-mongodb
在你的插件中添加对应的 require 以确保此插件在被引用前正确加载
```
from nonebot import requirerequire("nonebot_plugin_mongodb")
```## ⚙️ 配置
在 nonebot2 项目的`.env`文件中添加下表中的配置, 配置均为**非必须项**
### 通用配置项
| 配置项 | 必填 | 类型 | 默认值 | 说明 |
| :-----------------: | :--: | :--: | :------: | :----------------: |
| mongo_uri | ⭕ | str | None | MongoDB 的连接 uri |
| mongo_database_name | ❌ | str | nonebot2 | 连接的数据库名 |## 🎉 使用
> 如果你不是插件开发者,那么此部分无需阅读
> 参考 exmple 中的[示例代码](./example/beanie_usage.py)
在 nonebot 的 `startup` 阶段时,本插件会读取 `beanie.Document` 的全部子类并加载,因此开发者无需额外进行 `init_beanie` 即可直接使用,关于具体的操作方法可以参考 [beanie 文档](https://beanie-odm.dev/)。
## 🙏 感谢
在此感谢以下开发者(项目)对本项目做出的贡献:
- [nonebot-plugin-template](https://github.com/A-kirami/nonebot-plugin-template): 项目的 README 模板
## ⏳ Star 趋势
[](https://starchart.cc/Well2333/nonebot-plugin-mongodb)