diff options
| author | Victor Näslund <victor@sunet.se> | 2022-11-16 19:38:36 +0100 |
|---|---|---|
| committer | Victor Näslund <victor@sunet.se> | 2022-11-16 19:38:36 +0100 |
| commit | 49cd9e90ae5f9a374ccd73f4a064d89729cdfb5e (patch) | |
| tree | 01788862c606087c7a94e8493670e2d429a16c55 /src/soc_collector/db.py | |
| parent | 419862b9575f7a2254d777ab0e0d38a09e065603 (diff) | |
renamed key search to filter
Diffstat (limited to 'src/soc_collector/db.py')
| -rw-r--r-- | src/soc_collector/db.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/soc_collector/db.py b/src/soc_collector/db.py index d601a82..f537f4a 100644 --- a/src/soc_collector/db.py +++ b/src/soc_collector/db.py @@ -21,7 +21,7 @@ from bson import ObjectId class SearchInput(BaseModel): """Handle search data for HTTP request""" - search: Optional[Dict[str, Any]] + filter: Dict[str, Any] limit: int = 25 skip: int = 0 @@ -68,9 +68,9 @@ class DBClient: """ data: List[Dict[str, Any]] = [] - cursor = self.collection.find(search_data.search) + cursor = self.collection.find(search_data.filter) - cursor.sort({"ip": ASCENDING, "timestamp": DESCENDING}).limit(search_data.limit).skip(search_data.skip) + cursor.sort([("ip", ASCENDING), ("timestamp", DESCENDING)]).limit(search_data.limit).skip(search_data.skip) try: async for document in cursor: |
