def put_record(self, model_id, record, authors, record_id=None):
        doc = {
            'authors': authors,
            'record': record
        }

        if record_id is not None:
            try:
                old_doc = self.__get_raw_record(model_id, record_id)
            except backend_exceptions.RecordNotFound:
                doc['_id'] = record_id
            else:
                old_doc["record"].update(doc["record"])
                doc = old_doc
                doc['authors'] = list(set(authors) | set(old_doc['authors']))
        else:
            key_exist = functools.partial(self._record_exists, model_id)
            record_id = self._generate_id(key_exist=key_exist)
            doc['_id'] = record_id

        self._db['records'][model_id][record_id] = doc
        return record_id
dataset/ETHPy150Open spiral-project/daybed/daybed/backends/memory/__init__.py/MemoryBackend.put_record/original