prs_server/crud/crud_count_in_worker.py
2022-09-19 20:09:12 +08:00

34 lines
1.0 KiB
Python

from motor.motor_asyncio import AsyncIOMotorDatabase
import schemas
from crud.base import CRUDBase
__all__ = 'count_in_worker',
class CRUDCountInWorker(CRUDBase):
# 获取所有在职人员统计数据
async def all_count_info(self, db: AsyncIOMotorDatabase):
return await self.find_many(db, {}, {'_id': 0})
# 获取指定字段
async def find_count_some(self, db: AsyncIOMotorDatabase, find_list=[]):
find_where = {'_id': 0}
if find_list:
for key in find_list:
find_where.update({
key: 1
})
return await self.find_many(db, {}, find_where)
# 查询单条数据
async def find_one_count(self, db: AsyncIOMotorDatabase, count_id):
return await self.find_one(db, {'count_id': count_id}, {'_id': 0})
# 插入一条新的在职人员统计数据
async def insert_count_info(self, db: AsyncIOMotorDatabase, insertdata):
await self.insert_one(db, insertdata)
count_in_worker = CRUDCountInWorker('count_in_worker')