prs_server/crud/crud_count_in_worker.py
2022-07-28 15:04:03 +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, findlist=[]):
findWhere = {'_id': 0}
if findlist:
for key in findlist:
findWhere.update({
key: 1
})
return await self.find_many(db, {}, findWhere)
# 查询单条数据
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')