func (b *BulkDocument) Commit() ([]BulkDocumentResult, error) {
	if !b.closed {
		b.closed = true
		url, err := buildUrl(b.db.dbName, "_bulk_docs")
		if err != nil {
			return nil, err
		}
		var headers = make(map[string]string)
		headers["Content-Type"] = "application/json"
		headers["Accept"] = "application/json"
		bd := make(map[string]interface{})
		bd["docs"] = b.docs
		data, numBytes, err := encodeData(bd)
		if err != nil {
			return nil, err
		}
		headers["Content-Length"] = strconv.Itoa(numBytes)
		if numBytes > 4000 {
			headers["Expect"] = "100-continue"
		}
		resp, err := b.db.connection.request("POST", url, data, headers, b.db.auth)
		if err != nil {
			return nil, err
		}
		defer resp.Body.Close()
		return getBulkDocumentResult(resp)
	}
	return nil, fmt.Errorf("CouchDB: Bulk Document has already been executed")
}
Commit POST /{db}/_bulk_docs
package couchdb
import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
	"reflect"
	"strconv"
)
type bulkDoc struct {
	_id      string
	_rev     string
	_deleted bool
	doc      interface{}
}
func (b bulkDoc) MarshalJSON() ([]byte, error) {
	out := make(map[string]interface{})
	if !b._deleted {
		bValue := reflect.Indirect(reflect.ValueOf(b.doc))
		bType := bValue.Type()
		for i := 0; i < bType.NumField(); i++ {
			field := bType.Field(i)
			name := bType.Field(i).Name
			jsonKey := field.Tag.Get("json")
			if jsonKey == "" {
				jsonKey = name
			}
			out[jsonKey] = bValue.FieldByName(name).Interface()
		}
	} else {
		out["_deleted"] = true
	}
	out["_id"] = b._id
	if b._rev != "" {
		out["_rev"] = b._rev
	}
	return json.Marshal(out)
}
type BulkDocument struct {
	docs   []bulkDoc
	db     *Database
	closed bool
}
func (db *Database) NewBulkDocument() *BulkDocument {
	b := &BulkDocument{}
	b.db = db
	return b
}
func (b *BulkDocument) Save(doc interface{}, id, rev string) error {
	if id == "" {
		return fmt.Errorf("No ID specified")
	}
	b.docs = append(b.docs, bulkDoc{id, rev, false, doc})
	return nil
}
func (b *BulkDocument) Delete(id, rev string) error {
	if id == "" {
		return fmt.Errorf("No ID specified")
	}
	if rev == "" {
		return fmt.Errorf("No Revision specified")
	}
	b.docs = append(b.docs, bulkDoc{id, rev, true, nil})
	return nil
}
type BulkDocumentResult struct {
	Ok       bool    `json:"ok"`
	ID       string  `json:"id"`
	Revision string  `json:"rev"`
	Error    *string `json:"error"`
	Reason   *string `json:"reason"`
}
func getBulkDocumentResult(resp *http.Response) ([]BulkDocumentResult, error) {
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}
	var results []BulkDocumentResult
	err = json.Unmarshal(body, &results)
	if err != nil {
		return nil, err
	}
	return results, nil
}