def returner(ret):

    options = _get_options(ret)

    # Check to see if the database exists.
    _response = _request("GET", options['url'] + "_all_dbs")
    if options['db'] not in _response:

        # Make a PUT request to create the database.
        _response = _request("PUT", options['url'] + options['db'])

        # Confirm that the response back was simple 'ok': true.
        if 'ok' not in _response or _response['ok'] is not True:
            log.error('Unable to create database "{0}"'
                             .format(options['db']))
            log.error('Nothing logged! Lost data.')
            return
        log.info('Created database "{0}"'.format(options['db']))

    # Call _generate_doc to get a dict object of the document we're going to
    # shove into the database.
    doc = _generate_doc(ret)

    # Make the actual HTTP PUT request to create the doc.
    _response = _request("PUT",
                         options['url'] + options['db'] + "/" + doc['_id'],
                         'application/json',
                         json.dumps(doc))

    # Sanity check regarding the response..
    if 'ok' not in _response or _response['ok'] is not True:
        log.error('Unable to create document: "{0}"'.format(_response))
        log.error('Nothing logged! Lost data.')
Take in the return and shove it into the couchdb database.
dataset/ETHPy150Open saltstack/salt/salt/returners/couchdb_return.py/returner