Beispiel #1
0
 async def get(self):
     motor_client = MotorClient()
     collections = await motor_client.get_collections()
     data = []
     for i in collections:
         data.append({'name': i})
     self.write(true_return(data=data))
Beispiel #2
0
 def __init__(self, local_symbol, server, size=100):
     self.local_symbol = local_symbol
     self.size = size
     # 过期区域
     self.out_area = set()
     self.server = server
     # 当前正常区域
     self.cur_area = {}
     self.motor_client = MotorClient(collection_name=local_symbol)
Beispiel #3
0
async def filter(collection: list,
                 start: datetime = None,
                 end: datetime = None,
                 download: bool = False):
    data = []
    for colle in collection:
        """分隔每个种类"""
        if download:
            data.append(colle)
        """  对应条件查询 """
        motor_client = MotorClient(collection_name=colle)
        if start and end:
            cursor = motor_client.collection.find({
                "datetime": {
                    '$gte': start,
                    '$lte': end
                }
            }).sort('datetime')
            data.extend([
                document async for document in cursor
                if document.pop('_id', None) or 1
            ])
            continue
        elif start:
            cursor = motor_client.collection.find({
                "datetime": {
                    '$gte': start
                }
            }).sort('datetime')
            data.extend([
                document async for document in cursor
                if document.pop('_id', None) or 1
            ])
            continue
        elif end:
            cursor = motor_client.collection.find({
                "datetime": {
                    '$lte': end
                }
            }).sort('datetime')
            data.extend([
                document async for document in cursor
                if document.pop('_id', None) or 1
            ])
            continue
        else:
            cursor = motor_client.collection.find()
            data.extend([
                document async for document in cursor
                if document.pop('_id', None) or 1
            ])
    return data