func (d *Delete) Ordered(ordered bool) *Delete {
	if d == nil {
		d = new(Delete)
	}
	d.ordered = &ordered
	return d
}
Ordered sets ordered. If true, when a write fails, the operation will return the error, when
false write failures do not stop execution of the operation.
package operation
import (
	"context"
	"errors"
	"fmt"
	"go.mongodb.org/mongo-driver/event"
	"go.mongodb.org/mongo-driver/mongo/description"
	"go.mongodb.org/mongo-driver/mongo/writeconcern"
	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
	"go.mongodb.org/mongo-driver/x/mongo/driver"
	"go.mongodb.org/mongo-driver/x/mongo/driver/session"
)
type Delete struct {
	deletes      []bsoncore.Document
	ordered      *bool
	session      *session.Client
	clock        *session.ClusterClock
	collection   string
	monitor      *event.CommandMonitor
	crypt        *driver.Crypt
	database     string
	deployment   driver.Deployment
	selector     description.ServerSelector
	writeConcern *writeconcern.WriteConcern
	retry        *driver.RetryMode
	hint         *bool
	result       DeleteResult
}
type DeleteResult struct {
	N int32
}
func buildDeleteResult(response bsoncore.Document, srvr driver.Server) (DeleteResult, error) {
	elements, err := response.Elements()
	if err != nil {
		return DeleteResult{}, err
	}
	dr := DeleteResult{}
	for _, element := range elements {
		switch element.Key() {
		case "n":
			var ok bool
			dr.N, ok = element.Value().AsInt32OK()
			if !ok {
				err = fmt.Errorf("response field 'n' is type int32, but received BSON type %s", element.Value().Type)
			}
		}
	}
	return dr, nil
}
func NewDelete(deletes ...bsoncore.Document) *Delete {
	return &Delete{
		deletes: deletes,
	}
}
func (d *Delete) Result() DeleteResult { return d.result }
func (d *Delete) processResponse(response bsoncore.Document, srvr driver.Server, desc description.Server, _ int) error {
	dr, err := buildDeleteResult(response, srvr)
	d.result.N += dr.N
	return err
}
func (d *Delete) Execute(ctx context.Context) error {
	if d.deployment == nil {
		return errors.New("the Delete operation must have a Deployment set before Execute can be called")
	}
	batches := &driver.Batches{
		Identifier: "deletes",
		Documents:  d.deletes,
		Ordered:    d.ordered,
	}
	return driver.Operation{
		CommandFn:         d.command,
		ProcessResponseFn: d.processResponse,
		Batches:           batches,
		RetryMode:         d.retry,
		Type:              driver.Write,
		Client:            d.session,
		Clock:             d.clock,
		CommandMonitor:    d.monitor,
		Crypt:             d.crypt,
		Database:          d.database,
		Deployment:        d.deployment,
		Selector:          d.selector,
		WriteConcern:      d.writeConcern,
	}.Execute(ctx, nil)
}
func (d *Delete) command(dst []byte, desc description.SelectedServer) ([]byte, error) {
	dst = bsoncore.AppendStringElement(dst, "delete", d.collection)
	if d.ordered != nil {
		dst = bsoncore.AppendBooleanElement(dst, "ordered", *d.ordered)
	}
	if d.hint != nil && *d.hint {
		if desc.WireVersion == nil || !desc.WireVersion.Includes(5) {
			return nil, errors.New("the 'hint' command parameter requires a minimum server wire version of 5")
		}
		if !d.writeConcern.Acknowledged() {
			return nil, errUnacknowledgedHint
		}
	}
	return dst, nil
}
func (d *Delete) Deletes(deletes ...bsoncore.Document) *Delete {
	if d == nil {
		d = new(Delete)
	}
	d.deletes = deletes
	return d
}