func (db *DB) Copy(ctx context.Context, targetID, sourceID string, options ...Options) (targetRev string, err error) {
	opts, err := mergeOptions(options...)
	if err != nil {
		return "", err
	}
	if copier, ok := db.driverDB.(driver.Copier); ok {
		targetRev, err = copier.Copy(ctx, targetID, sourceID, opts)
		if errors.StatusCode(err) != StatusNotImplemented {
			return targetRev, err
		}
	}
	row, err := db.Get(ctx, sourceID, opts)
	if err != nil {
		return "", err
	}
	var doc map[string]interface{}
	if err = row.ScanDoc(&doc); err != nil {
		return "", err
	}
	delete(doc, "_rev")
	doc["_id"] = targetID
	return db.Put(ctx, targetID, doc)
}
// Copy copies the source document to a new document with an ID of targetID. If
// the database backend does not support COPY directly, the operation will be
// emulated with a Get followed by Put. The target will be an exact copy of the
// source, with only the ID and revision changed.
//
// See http://docs.couchdb.org/en/2.0.0/api/document/common.html#copy--db-docid
Copy copies the source document to a new document with an ID of targetID. If
the database backend does not support COPY directly, the operation will be
emulated with a Get followed by Put. The target will be an exact copy of the
source, with only the ID and revision changed.


// Copy copies the source document to a new document with an ID of targetID . If // the database backend does not support COPY directly the operation will be // emulated with a Get followed by Put . The target will be an exact copy of the // source with only the ID and revision changed . // // See http : // docs . couchdb . org / en / 2 . 0 . 0 / api / document / common . html#copy -- db - docid
func (db *DB) Copy(ctx context.Context, targetID, sourceID string, options ...Options) (targetRev string, err error) {
	opts, err := mergeOptions(options...)
	if err != nil {
		return "", err
	}
	if copier, ok := db.driverDB.(driver.Copier); ok {
		targetRev, err = copier.Copy(ctx, targetID, sourceID, opts)
		if errors.StatusCode(err) != StatusNotImplemented {
			return targetRev, err
		}
	}
	row, err := db.Get(ctx, sourceID, opts)
	if err != nil {
		return "", err
	}
	var doc map[string]interface{}
	if err = row.ScanDoc(&doc); err != nil {
		return "", err
	}
	delete(doc, "_rev")
	doc["_id"] = targetID
	return db.Put(ctx, targetID, doc)
}
func ( db * DB ) Copy ( ctx context . Context , targetID , sourceID string , options ... Options ) ( targetRev string , err error ) { opts , err := mergeOptions ( options ... ) if err != nil { return " " , err } if copier , ok := db . driverDB . ( driver . Copier ) ; ok { targetRev , err = copier . Copy ( ctx , targetID , sourceID , opts ) if errors . StatusCode ( err ) != StatusNotImplemented { return targetRev , err } } row , err := db . Get ( ctx , sourceID , opts ) if err != nil { return " " , err } var doc map [ string ] interface { } if err = row . ScanDoc ( & doc ) ; err != nil { return " " , err } delete ( doc , " " ) doc [ " " ] = targetID return db . Put ( ctx , targetID , doc ) }
Copy copies the source document to a new document with an ID of targetID.
Copy copies the source document to a new document with an ID of targetID .