<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _update(self, metadata, tx_id, resource_id):
 """Update and obj in bdb using the tx_id. :param metadata: new metadata for the transaction. :param tx_id: id of the transaction to be updated. :return: id of the transaction. """

        try:
            if not tx_id:
                sent_tx = self.write(metadata, resource_id)
                self.logger.debug('bdb::put::{}'.format(sent_tx['id']))
                return sent_tx
            else:
                txs = self.driver.instance.transactions.get(asset_id=self.get_asset_id(tx_id))
                unspent = txs[-1]
                sent_tx = self._put(metadata, unspent, resource_id)
                self.logger.debug('bdb::put::{}'.format(sent_tx))
                return sent_tx

        except BadRequest as e:
            logging.error(e)