# python-mongodb-orm **Repository Path**: vincenterWang/python-mongodb-orm ## Basic Information - **Project Name**: python-mongodb-orm - **Description**: No description available - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-08-18 - **Last Updated**: 2025-08-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 针对 pymongo 模块操作的二次封装 1. 参考 java 的 mybatisplus,将基本操作封装成wrappers进行快速构建原始sql 2. MongoDBClient 是mongo通信的入口,所有的操作都是基于该模块构建 ## 以下是操作示例 1 条件查询- 单查 find_one = mongo.find_one(QueryWrapper().eq('id',1)) print(find_one) 2 不含条件多数据查询 find_many = mongo.find_many() print([i for i in find_many]) 3 条件查询- 多数据查询 find_many = mongo.find_many(QueryWrapper().gte('id',0).lte('id',2)) print([i for i in find_many]) 4 单条数据插入 data = [{'id': 5, 'name': 'chentu', 'hobby': ['football', 'basketball']},{'id': 6, 'name': 'zhangsan', 'hobby': ['football', 'basketball']}] res = mongo.insert_many(data) print(res) 5 更新多条数据 res = mongo.update_many(UpdateWrapper().gt('id',4).set('name','zhaosi')) print(res) 6 替换文档 res = mongo.replace_one(QueryWrapper().eq('id',5),{'id': 5, 'name': 'chentu', 'hobby': ['nothing']}) print(res) 7 分页查询 res = mongo.page_find(QueryWrapper(),skip=0,limit=1) print([i for i in res])