pygsti.io.mongodb.add_dict_to_mongodb_write_ops

pygsti.io.mongodb.add_dict_to_mongodb_write_ops#

add_dict_to_mongodb_write_ops(d, write_ops, mongodb, collection_name, identifying_metadata, overwrite_existing)#

Similar to write_dict_to_mongodb, but just collect write operations and update a main-doc dictionary.

Parameters:
  • d (dict) – the dictionary of elements to serialize.

  • write_ops (WriteOpsByCollection) – An object that keeps track of pymongo write operations on a per-collection basis. This object accumulates write operations to be performed at some point in the future.

  • mongodb (pymongo.database.Database) – The MongoDB instance that is planned to be written to. Used to test for existing records and not to write to, as writing is assumed to be done later, potentially as a bulk write operation.

  • collection_name (str) – the MongoDB collection within mongodb that is planned to write to.

  • identifying_metadata (dict) – JSON-able metadata that identifies the dictionary being serialized. This metadata should be saved for later retrieving the elements of d from mongodb_collection.

  • overwrite_existing (bool, optional) – Whether existing documents should be overwritten. The default of False causes a ValueError to be raised if a document with the given doc_id already exists.

Return type:

None