MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / _get_timeseries_collection

Method _get_timeseries_collection

mongoengine/document.py:277–295  ·  view source on GitHub ↗

Create a new or get an existing timeseries PyMongo collection.

(cls)

Source from the content-addressed store, hash-verified

275
276 @classmethod
277 def _get_timeseries_collection(cls):
278 """Create a new or get an existing timeseries PyMongo collection."""
279 db = cls._get_db()
280 collection_name = cls._get_collection_name()
281 timeseries_opts = cls._meta.get("timeseries")
282
283 if collection_name in list_collection_names(
284 db, include_system_collections=True
285 ):
286 collection = db[collection_name]
287 collection.options()
288 return collection
289
290 opts = {"expireAfterSeconds": timeseries_opts.pop("expireAfterSeconds", None)}
291 return db.create_collection(
292 name=collection_name,
293 timeseries=timeseries_opts,
294 **opts,
295 )
296
297 def to_mongo(self, *args, **kwargs):
298 data = super().to_mongo(*args, **kwargs)

Callers 1

_get_collectionMethod · 0.80

Calls 5

list_collection_namesFunction · 0.90
_get_dbMethod · 0.80
popMethod · 0.80
_get_collection_nameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected