class_docstr: Non permanent database
  
  This database is meant for debugging purposes. It only lives through one execution and all
  information saved during it is lost when the process is terminated.
  
  .. seealso:: :class:`orion.core.io.database.Database` for more on attributes.
class_docstr_tok: ["Non","permanent","database","This","database","is","meant","for","debugging","purposes",".","It","only","lives","through","one","execution","and","all","information","saved","during","it","is","lost","when","the","process","is","terminated",".","..","seealso",":",":",":","class",":","`","orion.core.io.database.Database","`","for","more","on","attributes","."]
docstr: Read a collection's document and update the found document.
  
  Returns the updated document, or None if nothing found.
  
  .. seealso:: :meth:`orion.core.io.database.Database.read_and_write` for
               argument documentation.
docstr_tok: ["Read","a","collection","'s","document","and","update","the","found","document",".","Returns","the","updated","document",",","or","None","if","nothing","found",".","..","seealso",":",":",":","meth",":","`","orion.core.io.database.Database.read_and_write","`","for","argument","documentation","."]
code: def read_and_write(
      self, collection_name, query, data, selection=None
  ):
      """Read a collection's document and update the found document.
  
      Returns the updated document, or None if nothing found.
  
      .. seealso:: :meth:`orion.core.io.database.Database.read_and_write` for
                   argument documentation.
  
      """
      dbdoc = self.read(collection_name, query)
      if not dbdoc:
          return None
  
      id_query = {"_id": dbdoc[0]["_id"]}
      self.write(collection_name, data, id_query)
      return self.read(collection_name, id_query)[0]
  
imports: import copy
  from collections import defaultdict
  from orion.core.io.database import Database, DatabaseError, DuplicateKeyError
  from orion.core.utils.flatten import flatten, unflatten
label_desc: Use image node_id 10 for calling the EphemeralDB obj's underlying member method code with example usage: obj.read_and_write(collection_name, query, data, selection) and returns: self, None