Query multiple records (limit=0 means no limit)
(self, collection_suffix: str, query: Dict, limit: int = 0)
| 122 | return None |
| 123 | |
| 124 | async def find_many(self, collection_suffix: str, query: Dict, limit: int = 0) -> List[Dict]: |
| 125 | """Query multiple records (limit=0 means no limit)""" |
| 126 | try: |
| 127 | collection = await self.get_collection(collection_suffix) |
| 128 | cursor = collection.find(query) |
| 129 | if limit > 0: |
| 130 | cursor = cursor.limit(limit) |
| 131 | return await cursor.to_list(length=None) |
| 132 | except Exception as e: |
| 133 | utils.logger.error(f"[MongoDBStoreBase] Find many failed ({self.collection_prefix}_{collection_suffix}): {e}") |
| 134 | return [] |
| 135 | |
| 136 | async def create_index(self, collection_suffix: str, keys: List[tuple], unique: bool = False): |
| 137 | """Create index: keys=[("field", 1)]""" |