MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _DatabaseAggregationCommand

Class _DatabaseAggregationCommand

pymongo/synchronous/aggregation.py:233–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231
232
233class _DatabaseAggregationCommand(_AggregationCommand):
234 _target: Database[Any]
235
236 @property
237 def _aggregation_target(self) -> int:
238 return 1
239
240 @property
241 def _cursor_namespace(self) -> str:
242 return f"{self._target.name}.$cmd.aggregate"
243
244 @property
245 def _database(self) -> Database[Any]:
246 return self._target
247
248 def _cursor_collection(self, cursor: Mapping[str, Any]) -> Collection[Any]:
249 """The Collection used for the aggregate command cursor."""
250 # Collection level aggregate may not always return the "ns" field
251 # according to our MockupDB tests. Let's handle that case for db level
252 # aggregate too by defaulting to the <db>.$cmd.aggregate namespace.
253 _, collname = cursor.get("ns", self._cursor_namespace).split(".", 1)
254 return self._database[collname]

Callers 1

aggregateMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected