mongo-driver: go.mongodb.org/mongo-driver/x/mongo/driver Index | Files | Directories

package driver

import "go.mongodb.org/mongo-driver/x/mongo/driver"

Index

Package Files

abort_transaction.go aggregate.go batch_cursor.go bulk_write.go commit_transaction.go count.go count_documents.go create_indexes.go delete.go delete_indexes.go dispatch.go distinct.go drop_collection.go drop_database.go end_sessions.go find.go find_one_and_delete.go find_one_and_replace.go find_one_and_update.go insert.go kill_cursors.go list_collections.go list_collections_batch_cursor.go list_databases.go list_indexes.go models.go read.go read_cursor.go update.go write.go

Variables

var ErrArrayFilters = errors.New("array filters cannot be set for server versions < 3.6")

ErrArrayFilters is caused if array filters are given for an invalid server version.

var ErrCollation = errors.New("collation cannot be set for server versions < 3.4")

ErrCollation is caused if a collation is given for an invalid server version.

var ErrFilterType = errors.New("filter must be a string")

ErrFilterType is thrown when a non-string filter is specified.

func AbortTransaction Uses

func AbortTransaction(
    ctx context.Context,
    cmd command.AbortTransaction,
    topo *topology.Topology,
    selector description.ServerSelector,
) (result.TransactionResult, error)

AbortTransaction handles the full cycle dispatch and execution of abortting a transaction against the provided topology.

func BulkWrite Uses

func BulkWrite(
    ctx context.Context,
    ns command.Namespace,
    models []WriteModel,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    retryWrite bool,
    sess *session.Client,
    writeConcern *writeconcern.WriteConcern,
    clock *session.ClusterClock,
    registry *bsoncodec.Registry,
    opts ...*options.BulkWriteOptions,
) (result.BulkWrite, error)

BulkWrite handles the full dispatch cycle for a bulk write operation.

func CommitTransaction Uses

func CommitTransaction(
    ctx context.Context,
    cmd command.CommitTransaction,
    topo *topology.Topology,
    selector description.ServerSelector,
) (result.TransactionResult, error)

CommitTransaction handles the full cycle dispatch and execution of committing a transaction against the provided topology.

func Count Uses

func Count(
    ctx context.Context,
    cmd command.Count,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    registry *bsoncodec.Registry,
    opts ...*options.CountOptions,
) (int64, error)

Count handles the full cycle dispatch and execution of a count command against the provided topology.

func CountDocuments Uses

func CountDocuments(
    ctx context.Context,
    cmd command.CountDocuments,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    registry *bsoncodec.Registry,
    opts ...*options.CountOptions,
) (int64, error)

CountDocuments handles the full cycle dispatch and execution of a countDocuments command against the provided topology.

func CreateIndexes Uses

func CreateIndexes(
    ctx context.Context,
    cmd command.CreateIndexes,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    opts ...*options.CreateIndexesOptions,
) (result.CreateIndexes, error)

CreateIndexes handles the full cycle dispatch and execution of a createIndexes command against the provided topology.

func Delete Uses

func Delete(
    ctx context.Context,
    cmd command.Delete,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    retryWrite bool,
    opts ...*options.DeleteOptions,
) (result.Delete, error)

Delete handles the full cycle dispatch and execution of a delete command against the provided topology.

func Distinct Uses

func Distinct(
    ctx context.Context,
    cmd command.Distinct,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    opts ...*options.DistinctOptions,
) (result.Distinct, error)

Distinct handles the full cycle dispatch and execution of a distinct command against the provided topology.

func DropCollection Uses

func DropCollection(
    ctx context.Context,
    cmd command.DropCollection,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
) (bson.Raw, error)

DropCollection handles the full cycle dispatch and execution of a dropCollection command against the provided topology.

func DropDatabase Uses

func DropDatabase(
    ctx context.Context,
    cmd command.DropDatabase,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
) (bson.Raw, error)

DropDatabase handles the full cycle dispatch and execution of a dropDatabase command against the provided topology.

func DropIndexes Uses

func DropIndexes(
    ctx context.Context,
    cmd command.DropIndexes,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    opts ...*options.DropIndexesOptions,
) (bson.Raw, error)

DropIndexes handles the full cycle dispatch and execution of a dropIndexes command against the provided topology.

func EndSessions Uses

func EndSessions(
    ctx context.Context,
    cmd command.EndSessions,
    topo *topology.Topology,
    selector description.ServerSelector,
) ([]result.EndSessions, []error)

EndSessions handles the full cycle dispatch and execution of an endSessions command against the provided topology.

func FindOneAndDelete Uses

func FindOneAndDelete(
    ctx context.Context,
    cmd command.FindOneAndDelete,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    retryWrite bool,
    registry *bsoncodec.Registry,
    opts ...*options.FindOneAndDeleteOptions,
) (result.FindAndModify, error)

FindOneAndDelete handles the full cycle dispatch and execution of a FindOneAndDelete command against the provided topology.

func FindOneAndReplace Uses

func FindOneAndReplace(
    ctx context.Context,
    cmd command.FindOneAndReplace,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    retryWrite bool,
    registry *bsoncodec.Registry,
    opts ...*options.FindOneAndReplaceOptions,
) (result.FindAndModify, error)

FindOneAndReplace handles the full cycle dispatch and execution of a FindOneAndReplace command against the provided topology.

func FindOneAndUpdate Uses

func FindOneAndUpdate(
    ctx context.Context,
    cmd command.FindOneAndUpdate,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    retryWrite bool,
    registry *bsoncodec.Registry,
    opts ...*options.FindOneAndUpdateOptions,
) (result.FindAndModify, error)

FindOneAndUpdate handles the full cycle dispatch and execution of a FindOneAndUpdate command against the provided topology.

func Insert Uses

func Insert(
    ctx context.Context,
    cmd command.Insert,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    retryWrite bool,
    opts ...*options.InsertManyOptions,
) (result.Insert, error)

Insert handles the full cycle dispatch and execution of an insert command against the provided topology.

func KillCursors Uses

func KillCursors(
    ctx context.Context,
    ns command.Namespace,
    server *topology.Server,
    cursorID int64,
) (result.KillCursors, error)

KillCursors handles the full cycle dispatch and execution of an aggregate command against the provided topology.

func ListDatabases Uses

func ListDatabases(
    ctx context.Context,
    cmd command.ListDatabases,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    opts ...*options.ListDatabasesOptions,
) (result.ListDatabases, error)

ListDatabases handles the full cycle dispatch and execution of a listDatabases command against the provided topology.

func Read Uses

func Read(
    ctx context.Context,
    cmd command.Read,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
) (bson.Raw, error)

Read handles the full cycle dispatch and execution of a read command against the provided topology.

func Update Uses

func Update(
    ctx context.Context,
    cmd command.Update,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    retryWrite bool,
    opts ...*options.UpdateOptions,
) (result.Update, error)

Update handles the full cycle dispatch and execution of an update command against the provided topology.

func Write Uses

func Write(
    ctx context.Context,
    cmd command.Write,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
) (bson.Raw, error)

Write handles the full cycle dispatch and execution of a write command against the provided topology.

type BatchCursor Uses

type BatchCursor struct {
    // contains filtered or unexported fields
}

BatchCursor is a batch implementation of a cursor. It returns documents in entire batches instead of one at a time. An individual document cursor can be built on top of this batch cursor.

func Aggregate Uses

func Aggregate(
    ctx context.Context,
    cmd command.Aggregate,
    topo *topology.Topology,
    readSelector, writeSelector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    registry *bsoncodec.Registry,
    opts ...*options.AggregateOptions,
) (*BatchCursor, error)

Aggregate handles the full cycle dispatch and execution of an aggregate command against the provided topology.

func Find Uses

func Find(
    ctx context.Context,
    cmd command.Find,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    registry *bsoncodec.Registry,
    opts ...*options.FindOptions,
) (*BatchCursor, error)

Find handles the full cycle dispatch and execution of a find command against the provided topology.

func ListIndexes Uses

func ListIndexes(
    ctx context.Context,
    cmd command.ListIndexes,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    opts ...*options.ListIndexesOptions,
) (*BatchCursor, error)

ListIndexes handles the full cycle dispatch and execution of a listIndexes command against the provided topology.

func NewBatchCursor Uses

func NewBatchCursor(result bsoncore.Document, clientSession *session.Client, clock *session.ClusterClock, server *topology.Server, opts ...bsonx.Elem) (*BatchCursor, error)

NewBatchCursor creates a new BatchCursor from the provided parameters.

func NewEmptyBatchCursor Uses

func NewEmptyBatchCursor() *BatchCursor

NewEmptyBatchCursor returns a batch cursor that is empty.

func NewLegacyBatchCursor Uses

func NewLegacyBatchCursor(ns command.Namespace, cursorID int64, ds *bsoncore.DocumentSequence, limit int32, batchSize int32, server *topology.Server) (*BatchCursor, error)

NewLegacyBatchCursor creates a new BatchCursor for server versions 3.0 and below from the provided parameters.

TODO(GODRIVER-617): The batch parameter here should be []bsoncore.Document. Change it to this once we have the new wiremessage package that uses bsoncore instead of bson.

func ReadCursor Uses

func ReadCursor(
    ctx context.Context,
    cmd command.Read,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    cursorOpts ...bsonx.Elem,
) (*BatchCursor, error)

ReadCursor handles the full dispatch cycle and execution of a read command against the provided topology and returns a Cursor over the resulting BSON reader.

func (*BatchCursor) Batch Uses

func (bc *BatchCursor) Batch() *bsoncore.DocumentSequence

Batch will return a DocumentSequence for the current batch of documents. The returned DocumentSequence is only valid until the next call to Next or Close.

func (*BatchCursor) Close Uses

func (bc *BatchCursor) Close(ctx context.Context) error

Close closes this batch cursor.

func (*BatchCursor) Err Uses

func (bc *BatchCursor) Err() error

Err returns the latest error encountered.

func (*BatchCursor) ID Uses

func (bc *BatchCursor) ID() int64

ID returns the cursor ID for this batch cursor.

func (*BatchCursor) Next Uses

func (bc *BatchCursor) Next(ctx context.Context) bool

Next indicates if there is another batch available. Returning false does not necessarily indicate that the cursor is closed. This method will return false when an empty batch is returned.

If Next returns true, there is a valid batch of documents available. If Next returns false, there is not a valid batch of documents available.

func (*BatchCursor) Server Uses

func (bc *BatchCursor) Server() *topology.Server

Server returns a pointer to the cursor's server.

type BulkWriteError Uses

type BulkWriteError struct {
    result.WriteError
    Model WriteModel
}

BulkWriteError is an error from one operation in a bulk write.

type BulkWriteException Uses

type BulkWriteException struct {
    WriteConcernError *result.WriteConcernError
    WriteErrors       []BulkWriteError
}

BulkWriteException is a collection of errors returned by a bulk write operation.

func (BulkWriteException) Error Uses

func (BulkWriteException) Error() string

type DeleteManyModel Uses

type DeleteManyModel struct {
    Filter    interface{}
    Collation *options.Collation
}

DeleteManyModel is the write model for deleteMany operations.

type DeleteOneModel Uses

type DeleteOneModel struct {
    Filter    interface{}
    Collation *options.Collation
}

DeleteOneModel is the write model for delete operations.

type InsertOneModel Uses

type InsertOneModel struct {
    Document interface{}
}

InsertOneModel is the write model for insert operations.

type ListCollectionsBatchCursor Uses

type ListCollectionsBatchCursor struct {
    // contains filtered or unexported fields
}

ListCollectionsBatchCursor is a special batch cursor returned from ListCollections that properly handles current and legacy ListCollections operations.

func ListCollections Uses

func ListCollections(
    ctx context.Context,
    cmd command.ListCollections,
    topo *topology.Topology,
    selector description.ServerSelector,
    clientID uuid.UUID,
    pool *session.Pool,
    opts ...*options.ListCollectionsOptions,
) (*ListCollectionsBatchCursor, error)

ListCollections handles the full cycle dispatch and execution of a listCollections command against the provided topology.

func NewLegacyListCollectionsBatchCursor Uses

func NewLegacyListCollectionsBatchCursor(bc *BatchCursor) (*ListCollectionsBatchCursor, error)

NewLegacyListCollectionsBatchCursor creates a new legacy ListCollectionsCursor.

func NewListCollectionsBatchCursor Uses

func NewListCollectionsBatchCursor(bc *BatchCursor) (*ListCollectionsBatchCursor, error)

NewListCollectionsBatchCursor creates a new non-legacy ListCollectionsCursor.

func (*ListCollectionsBatchCursor) Batch Uses

func (lcbc *ListCollectionsBatchCursor) Batch() *bsoncore.DocumentSequence

Batch will return a DocumentSequence for the current batch of documents. The returned DocumentSequence is only valid until the next call to Next or Close.

func (*ListCollectionsBatchCursor) Close Uses

func (lcbc *ListCollectionsBatchCursor) Close(ctx context.Context) error

Close closes this batch cursor.

func (*ListCollectionsBatchCursor) Err Uses

func (lcbc *ListCollectionsBatchCursor) Err() error

Err returns the latest error encountered.

func (*ListCollectionsBatchCursor) ID Uses

func (lcbc *ListCollectionsBatchCursor) ID() int64

ID returns the cursor ID for this batch cursor.

func (*ListCollectionsBatchCursor) Next Uses

func (lcbc *ListCollectionsBatchCursor) Next(ctx context.Context) bool

Next indicates if there is another batch available. Returning false does not necessarily indicate that the cursor is closed. This method will return false when an empty batch is returned.

If Next returns true, there is a valid batch of documents available. If Next returns false, there is not a valid batch of documents available.

func (*ListCollectionsBatchCursor) Server Uses

func (lcbc *ListCollectionsBatchCursor) Server() *topology.Server

Server returns a pointer to the cursor's server.

type ReplaceOneModel Uses

type ReplaceOneModel struct {
    Filter      interface{}
    Replacement interface{}
    UpdateModel
}

ReplaceOneModel is the write model for replace operations.

type UpdateManyModel Uses

type UpdateManyModel struct {
    Filter interface{}
    Update interface{}
    // default is to not send a value. for servers < 3.6, error raised if value given. for unack writes using opcodes,
    // error raised if value given
    ArrayFilters    options.ArrayFilters
    ArrayFiltersSet bool
    UpdateModel
}

UpdateManyModel is the write model for updateMany operations.

type UpdateModel Uses

type UpdateModel struct {
    Collation *options.Collation
    Upsert    bool
    UpsertSet bool
}

UpdateModel contains the fields that are shared between the ReplaceOneModel, UpdateOneModel, and UpdateManyModel types

type UpdateOneModel Uses

type UpdateOneModel struct {
    Filter interface{}
    Update interface{}
    // default is to not send a value. for servers < 3.6, error raised if value given. for unack writes using opcodes,
    // error raised if value given
    ArrayFilters    options.ArrayFilters
    ArrayFiltersSet bool
    UpdateModel
}

UpdateOneModel is the write model for update operations.

type WriteModel Uses

type WriteModel interface {
    // contains filtered or unexported methods
}

WriteModel is the interface satisfied by all models for bulk writes.

Directories

PathSynopsis
authPackage auth is not for public use.
integration
session
topologyPackage topology contains types that handles the discovery, monitoring, and selection of servers.
uuid

Package driver imports 21 packages (graph) and is imported by 4 packages. Updated 2019-03-24. Refresh now. Tools for package owners.