versioned_collection.collection.tracking_collections.stash module

class versioned_collection.collection.tracking_collections.stash.StashCollection(*args: Any, **kwargs: Any)[source]

Bases: _BaseTrackerCollection

Stores the stash data of a collection.

class versioned_collection.collection.tracking_collections.stash.StashContainer(database: pymongo.database.Database, parent_collection_name: str, **kwargs)[source]

Bases: object

Container class managing the stash area.

When the state of the tracked collection is stashed, the modified documents of the tracked collection and the tracking documents from the corresponding ModifiedCollection are backed-up in two StashCollection collections. When the stashed data is restored, it is transferred back to the two corresponding collections and the stash area is cleared.

drop()[source]
exists() bool[source]
rename(new_name: str, *args, **kwargs)[source]
stash(main_collection: pymongo.collection.Collection, modified_collection: ModifiedCollection) None[source]

Copy the modified documents and the trackers to the stashing space.

Note

This does not modify the original collections.

Warning

This overwrites the existing stashed collections.

Parameters:
  • main_collection – The tracked versioned collection.

  • modified_collection – The collection that tracks the ids of the modified documents, i.e., __modified_<tracked_collection_name>.

stash_apply(main_collection: pymongo.collection.Collection, modified_collection: ModifiedCollection) None[source]

Apply the stash to restore the main collection.

Parameters:
  • main_collection – The tracked versioned collection

  • modified_collection – The collection that tracks the ids of the modified documents, i.e., __modified_<tracked_collection_name>.