func (iv IndexView) List(ctx context.Context, opts ...*options.ListIndexesOptions) (*Cursor, error) {
	if ctx == nil {
		ctx = context.Background()
	}

	sess := sessionFromContext(ctx)
	if sess == nil && iv.coll.client.sessionPool != nil {
		var err error
		sess, err = session.NewClientSession(iv.coll.client.sessionPool, iv.coll.client.id, session.Implicit)
		if err != nil {
			return nil, err
		}
	}

	err := iv.coll.client.validSession(sess)
	if err != nil {
		closeImplicitSession(sess)
		return nil, err
	}

	selector := description.CompositeSelector([]description.ServerSelector{
		description.ReadPrefSelector(readpref.Primary()),
		description.LatencySelector(iv.coll.client.localThreshold),
	})
	selector = makeReadPrefSelector(sess, selector, iv.coll.client.localThreshold)
	op := operation.NewListIndexes().
		Session(sess).CommandMonitor(iv.coll.client.monitor).
		ServerSelector(selector).ClusterClock(iv.coll.client.clock).
		Database(iv.coll.db.name).Collection(iv.coll.name).
		Deployment(iv.coll.client.deployment)

	var cursorOpts driver.CursorOptions
	lio := options.MergeListIndexesOptions(opts...)
	if lio.BatchSize != nil {
		op = op.BatchSize(*lio.BatchSize)
		cursorOpts.BatchSize = *lio.BatchSize
	}
	if lio.MaxTime != nil {
		op = op.MaxTimeMS(int64(*lio.MaxTime / time.Millisecond))
	}
	retry := driver.RetryNone
	if iv.coll.client.retryReads {
		retry = driver.RetryOncePerCommand
	}
	op.Retry(retry)

	err = op.Execute(ctx)
	if err != nil {
		// for namespaceNotFound errors, return an empty cursor and do not throw an error
		closeImplicitSession(sess)
		if isNamespaceNotFoundError(err) {
			return newEmptyCursor(), nil
		}

		return nil, replaceErrors(err)
	}

	bc, err := op.Result(cursorOpts)
	if err != nil {
		closeImplicitSession(sess)
		return nil, replaceErrors(err)
	}
	cursor, err := newCursorWithSession(bc, iv.coll.registry, sess)
	return cursor, replaceErrors(err)
}
// List executes a listIndexes command and returns a cursor over the indexes in the collection.
//
// The opts parameter can be used to specify options for this operation (see the options.ListIndexesOptions
// documentation).
//
// For more information about the command, see https://docs.mongodb.com/manual/reference/command/listIndexes/.
List executes a listIndexes command and returns a cursor over the indexes in the collection.

The opts parameter can be used to specify options for this operation (see the options.ListIndexesOptions
documentation).


// List executes a listIndexes command and returns a cursor over the indexes in the collection . // // The opts parameter can be used to specify options for this operation ( see the options . ListIndexesOptions // documentation ) . // // For more information about the command see https : // docs . mongodb . com / manual / reference / command / listIndexes / .
func (iv IndexView) List(ctx context.Context, opts ...*options.ListIndexesOptions) (*Cursor, error) {
	if ctx == nil {
		ctx = context.Background()
	}
	sess := sessionFromContext(ctx)
	if sess == nil && iv.coll.client.sessionPool != nil {
		var err error
		sess, err = session.NewClientSession(iv.coll.client.sessionPool, iv.coll.client.id, session.Implicit)
		if err != nil {
			return nil, err
		}
	}
	err := iv.coll.client.validSession(sess)
	if err != nil {
		closeImplicitSession(sess)
		return nil, err
	}
	selector := description.CompositeSelector([]description.ServerSelector{
		description.ReadPrefSelector(readpref.Primary()),
		description.LatencySelector(iv.coll.client.localThreshold),
	})
	selector = makeReadPrefSelector(sess, selector, iv.coll.client.localThreshold)
	op := operation.NewListIndexes().
		Session(sess).CommandMonitor(iv.coll.client.monitor).
		ServerSelector(selector).ClusterClock(iv.coll.client.clock).
		Database(iv.coll.db.name).Collection(iv.coll.name).
		Deployment(iv.coll.client.deployment)
	var cursorOpts driver.CursorOptions
	lio := options.MergeListIndexesOptions(opts...)
	if lio.BatchSize != nil {
		op = op.BatchSize(*lio.BatchSize)
		cursorOpts.BatchSize = *lio.BatchSize
	}
	if lio.MaxTime != nil {
		op = op.MaxTimeMS(int64(*lio.MaxTime / time.Millisecond))
	}
	retry := driver.RetryNone
	if iv.coll.client.retryReads {
		retry = driver.RetryOncePerCommand
	}
	op.Retry(retry)
	err = op.Execute(ctx)
	if err != nil {
		closeImplicitSession(sess)
		if isNamespaceNotFoundError(err) {
			return newEmptyCursor(), nil
		}
		return nil, replaceErrors(err)
	}
	bc, err := op.Result(cursorOpts)
	if err != nil {
		closeImplicitSession(sess)
		return nil, replaceErrors(err)
	}
	cursor, err := newCursorWithSession(bc, iv.coll.registry, sess)
	return cursor, replaceErrors(err)
}
func ( iv IndexView ) List ( ctx context . Context , opts ... * options . ListIndexesOptions ) ( * Cursor , error ) { if ctx == nil { ctx = context . Background ( ) } sess := sessionFromContext ( ctx ) if sess == nil && iv . coll . client . sessionPool != nil { var err error sess , err = session . NewClientSession ( iv . coll . client . sessionPool , iv . coll . client . id , session . Implicit ) if err != nil { return nil , err } } err := iv . coll . client . validSession ( sess ) if err != nil { closeImplicitSession ( sess ) return nil , err } selector := description . CompositeSelector ( [ ] description . ServerSelector { description . ReadPrefSelector ( readpref . Primary ( ) ) , description . LatencySelector ( iv . coll . client . localThreshold ) , } ) selector = makeReadPrefSelector ( sess , selector , iv . coll . client . localThreshold ) op := operation . NewListIndexes ( ) . Session ( sess ) . CommandMonitor ( iv . coll . client . monitor ) . ServerSelector ( selector ) . ClusterClock ( iv . coll . client . clock ) . Database ( iv . coll . db . name ) . Collection ( iv . coll . name ) . Deployment ( iv . coll . client . deployment ) var cursorOpts driver . CursorOptions lio := options . MergeListIndexesOptions ( opts ... ) if lio . BatchSize != nil { op = op . BatchSize ( * lio . BatchSize ) cursorOpts . BatchSize = * lio . BatchSize } if lio . MaxTime != nil { op = op . MaxTimeMS ( int64 ( * lio . MaxTime / time . Millisecond ) ) } retry := driver . RetryNone if iv . coll . client . retryReads { retry = driver . RetryOncePerCommand } op . Retry ( retry ) err = op . Execute ( ctx ) if err != nil { closeImplicitSession ( sess ) if isNamespaceNotFoundError ( err ) { return newEmptyCursor ( ) , nil } return nil , replaceErrors ( err ) } bc , err := op . Result ( cursorOpts ) if err != nil { closeImplicitSession ( sess ) return nil , replaceErrors ( err ) } cursor , err := newCursorWithSession ( bc , iv . coll . registry , sess ) return cursor , replaceErrors ( err ) }
List executes a listIndexes command and returns a cursor over the indexes in the collection.
List executes a listIndexes command and returns a cursor over the indexes in the collection .
// for namespaceNotFound errors, return an empty cursor and do not throw an error