Documentation ¶
Overview ¶
Package command contains abstractions for operations that can be performed against a MongoDB deployment. The types in this package are meant to provide a general set of commands that a user can run against a MongoDB database without knowing the version of the database.
Each type consists of two levels of interaction. The lowest level are the Encode and Decode methods. These are meant to be symmetric eventually, but currently only support the driver side of commands. The higher level is the RoundTrip method. This only makes sense from the driver side of commands and this method handles the encoding of the request and decoding of the response using the given wiremessage.ReadWriter.
Index ¶
- Constants
- Variables
- func ClientDoc(app string) *bson.Document
- func IsNotFound(err error) bool
- type Aggregate
- func (a *Aggregate) Decode(desc description.SelectedServer, cb CursorBuilder, wm wiremessage.WireMessage) *Aggregate
- func (a *Aggregate) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (a *Aggregate) Err() error
- func (a *Aggregate) HasDollarOut() bool
- func (a *Aggregate) Result() (Cursor, error)
- func (a *Aggregate) RoundTrip(ctx context.Context, desc description.SelectedServer, cb CursorBuilder, ...) (Cursor, error)
- type BuildInfo
- func (bi *BuildInfo) Decode(wm wiremessage.WireMessage) *BuildInfo
- func (bi *BuildInfo) Encode() (wiremessage.WireMessage, error)
- func (bi *BuildInfo) Err() error
- func (bi *BuildInfo) Result() (result.BuildInfo, error)
- func (bi *BuildInfo) RoundTrip(ctx context.Context, rw wiremessage.ReadWriter) (result.BuildInfo, error)
- type Count
- func (c *Count) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Count
- func (c *Count) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (c *Count) Err() error
- func (c *Count) Result() (int64, error)
- func (c *Count) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (int64, error)
- type CreateIndexes
- func (ci *CreateIndexes) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *CreateIndexes
- func (ci *CreateIndexes) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (ci *CreateIndexes) Err() error
- func (ci *CreateIndexes) Result() (result.CreateIndexes, error)
- func (ci *CreateIndexes) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (result.CreateIndexes, error)
- type Cursor
- type CursorBuilder
- type Delete
- func (d *Delete) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Delete
- func (d *Delete) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (d *Delete) Err() error
- func (d *Delete) Result() (result.Delete, error)
- func (d *Delete) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (result.Delete, error)
- type Distinct
- func (d *Distinct) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Distinct
- func (d *Distinct) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (d *Distinct) Err() error
- func (d *Distinct) Result() (result.Distinct, error)
- func (d *Distinct) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (result.Distinct, error)
- type DropCollection
- func (dc *DropCollection) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *DropCollection
- func (dc *DropCollection) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (dc *DropCollection) Err() error
- func (dc *DropCollection) Result() (bson.Reader, error)
- func (dc *DropCollection) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (bson.Reader, error)
- type DropDatabase
- func (dd *DropDatabase) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *DropDatabase
- func (dd *DropDatabase) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (dd *DropDatabase) Err() error
- func (dd *DropDatabase) Result() (bson.Reader, error)
- func (dd *DropDatabase) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (bson.Reader, error)
- type DropIndexes
- func (di *DropIndexes) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *DropIndexes
- func (di *DropIndexes) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (di *DropIndexes) Err() error
- func (di *DropIndexes) Result() (bson.Reader, error)
- func (di *DropIndexes) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (bson.Reader, error)
- type EndSessions
- func (es *EndSessions) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *EndSessions
- func (es *EndSessions) Encode(desc description.SelectedServer) ([]wiremessage.WireMessage, error)
- func (es *EndSessions) Result() ([]result.EndSessions, []error)
- func (es *EndSessions) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) ([]result.EndSessions, []error)
- type Error
- type Find
- func (f *Find) Decode(desc description.SelectedServer, cb CursorBuilder, wm wiremessage.WireMessage) *Find
- func (f *Find) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (f *Find) Err() error
- func (f *Find) Result() (Cursor, error)
- func (f *Find) RoundTrip(ctx context.Context, desc description.SelectedServer, cb CursorBuilder, ...) (Cursor, error)
- type FindOneAndDelete
- func (f *FindOneAndDelete) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *FindOneAndDelete
- func (f *FindOneAndDelete) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (f *FindOneAndDelete) Err() error
- func (f *FindOneAndDelete) Result() (result.FindAndModify, error)
- func (f *FindOneAndDelete) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (result.FindAndModify, error)
- type FindOneAndReplace
- func (f *FindOneAndReplace) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *FindOneAndReplace
- func (f *FindOneAndReplace) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (f *FindOneAndReplace) Err() error
- func (f *FindOneAndReplace) Result() (result.FindAndModify, error)
- func (f *FindOneAndReplace) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (result.FindAndModify, error)
- type FindOneAndUpdate
- func (f *FindOneAndUpdate) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *FindOneAndUpdate
- func (f *FindOneAndUpdate) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (f *FindOneAndUpdate) Err() error
- func (f *FindOneAndUpdate) Result() (result.FindAndModify, error)
- func (f *FindOneAndUpdate) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (result.FindAndModify, error)
- type GetLastError
- func (gle *GetLastError) Decode(wm wiremessage.WireMessage) *GetLastError
- func (gle *GetLastError) Encode() (wiremessage.WireMessage, error)
- func (gle *GetLastError) Err() error
- func (gle *GetLastError) Result() (result.GetLastError, error)
- func (gle *GetLastError) RoundTrip(ctx context.Context, rw wiremessage.ReadWriter) (result.GetLastError, error)
- type GetMore
- func (gm *GetMore) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *GetMore
- func (gm *GetMore) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (gm *GetMore) Err() error
- func (gm *GetMore) Result() (bson.Reader, error)
- func (gm *GetMore) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (bson.Reader, error)
- type Handshake
- func (h *Handshake) Decode(wm wiremessage.WireMessage) *Handshake
- func (h *Handshake) Encode() (wiremessage.WireMessage, error)
- func (h *Handshake) Err() error
- func (h *Handshake) Handshake(ctx context.Context, addr address.Address, rw wiremessage.ReadWriter) (description.Server, error)
- func (h *Handshake) Result(addr address.Address) (description.Server, error)
- type Insert
- func (i *Insert) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Insert
- func (i *Insert) Encode(desc description.SelectedServer) ([]wiremessage.WireMessage, error)
- func (i *Insert) Err() error
- func (i *Insert) Result() (result.Insert, error)
- func (i *Insert) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (result.Insert, error)
- type IsMaster
- func (im *IsMaster) Decode(wm wiremessage.WireMessage) *IsMaster
- func (im *IsMaster) Encode() (wiremessage.WireMessage, error)
- func (im *IsMaster) Err() error
- func (im *IsMaster) Result() (result.IsMaster, error)
- func (im *IsMaster) RoundTrip(ctx context.Context, rw wiremessage.ReadWriter) (result.IsMaster, error)
- type KillCursors
- func (kc *KillCursors) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *KillCursors
- func (kc *KillCursors) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (kc *KillCursors) Err() error
- func (kc *KillCursors) Result() (result.KillCursors, error)
- func (kc *KillCursors) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (result.KillCursors, error)
- type ListCollections
- func (lc *ListCollections) Decode(desc description.SelectedServer, cb CursorBuilder, wm wiremessage.WireMessage) *ListCollections
- func (lc *ListCollections) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (lc *ListCollections) Err() error
- func (lc *ListCollections) Result() (Cursor, error)
- func (lc *ListCollections) RoundTrip(ctx context.Context, desc description.SelectedServer, cb CursorBuilder, ...) (Cursor, error)
- type ListDatabases
- func (ld *ListDatabases) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *ListDatabases
- func (ld *ListDatabases) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (ld *ListDatabases) Err() error
- func (ld *ListDatabases) Result() (result.ListDatabases, error)
- func (ld *ListDatabases) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (result.ListDatabases, error)
- type ListIndexes
- func (li *ListIndexes) Decode(desc description.SelectedServer, cb CursorBuilder, wm wiremessage.WireMessage) *ListIndexes
- func (li *ListIndexes) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (li *ListIndexes) Err() error
- func (li *ListIndexes) Result() (Cursor, error)
- func (li *ListIndexes) RoundTrip(ctx context.Context, desc description.SelectedServer, cb CursorBuilder, ...) (Cursor, error)
- type Namespace
- type QueryFailureError
- type Read
- func (r *Read) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Read
- func (r *Read) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (r *Read) Err() error
- func (r *Read) Result() (bson.Reader, error)
- func (r *Read) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (bson.Reader, error)
- type ResponseError
- type StartSession
- func (ss *StartSession) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *StartSession
- func (ss *StartSession) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (ss *StartSession) Err() error
- func (ss *StartSession) Result() (result.StartSession, error)
- func (ss *StartSession) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (result.StartSession, error)
- type Update
- func (u *Update) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Update
- func (u *Update) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (u *Update) Err() error
- func (u *Update) Result() (result.Update, error)
- func (u *Update) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (result.Update, error)
- type Write
- func (w *Write) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Write
- func (w *Write) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
- func (w *Write) Err() error
- func (w *Write) Result() (bson.Reader, error)
- func (w *Write) RoundTrip(ctx context.Context, desc description.SelectedServer, ...) (bson.Reader, error)
Constants ¶
const BatchSize = 10000
BatchSize is the max number of sessions to be included in 1 endSessions command.
Variables ¶
var ( // ErrUnknownCommandFailure occurs when a command fails for an unknown reason. ErrUnknownCommandFailure = errors.New("unknown command failure") // ErrNoCommandResponse occurs when the server sent no response document to a command. ErrNoCommandResponse = errors.New("no command response document") // ErrMultiDocCommandResponse occurs when the server sent multiple documents in response to a command. ErrMultiDocCommandResponse = errors.New("command returned multiple documents") // ErrNoDocCommandResponse occurs when the server indicated a response existed, but none was found. ErrNoDocCommandResponse = errors.New("command returned no documents") )
var ErrUnacknowledgedWrite = errors.New("unacknowledged write")
ErrUnacknowledgedWrite is returned from functions that have an unacknowledged write concern.
Functions ¶
func IsNotFound ¶
IsNotFound indicates if the error is from a namespace not being found.
Types ¶
type Aggregate ¶
type Aggregate struct { NS Namespace Pipeline *bson.Array Opts []option.AggregateOptioner ReadPref *readpref.ReadPref WriteConcern *writeconcern.WriteConcern ReadConcern *readconcern.ReadConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
Aggregate represents the aggregate command.
The aggregate command performs an aggregation.
func (*Aggregate) Decode ¶
func (a *Aggregate) Decode(desc description.SelectedServer, cb CursorBuilder, wm wiremessage.WireMessage) *Aggregate
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*Aggregate) Encode ¶
func (a *Aggregate) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*Aggregate) HasDollarOut ¶
HasDollarOut returns true if the Pipeline field contains a $out stage.
func (*Aggregate) Result ¶
Result returns the result of a decoded wire message and server description.
func (*Aggregate) RoundTrip ¶
func (a *Aggregate) RoundTrip(ctx context.Context, desc description.SelectedServer, cb CursorBuilder, rw wiremessage.ReadWriter) (Cursor, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type BuildInfo ¶
type BuildInfo struct {
// contains filtered or unexported fields
}
BuildInfo represents the buildInfo command.
The buildInfo command is used for getting the build information for a MongoDB server.
func (*BuildInfo) Decode ¶
func (bi *BuildInfo) Decode(wm wiremessage.WireMessage) *BuildInfo
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*BuildInfo) Encode ¶
func (bi *BuildInfo) Encode() (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*BuildInfo) Result ¶
Result returns the result of a decoded wire message and server description.
func (*BuildInfo) RoundTrip ¶
func (bi *BuildInfo) RoundTrip(ctx context.Context, rw wiremessage.ReadWriter) (result.BuildInfo, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type Count ¶
type Count struct { NS Namespace Query *bson.Document Opts []option.CountOptioner ReadPref *readpref.ReadPref ReadConcern *readconcern.ReadConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
Count represents the count command.
The count command counts how many documents in a collection match the given query.
func (*Count) Decode ¶
func (c *Count) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Count
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*Count) Encode ¶
func (c *Count) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*Count) RoundTrip ¶
func (c *Count) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (int64, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type CreateIndexes ¶
type CreateIndexes struct { NS Namespace Indexes *bson.Array Opts []option.CreateIndexesOptioner WriteConcern *writeconcern.WriteConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
CreateIndexes represents the createIndexes command.
The createIndexes command creates indexes for a namespace.
func (*CreateIndexes) Decode ¶
func (ci *CreateIndexes) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *CreateIndexes
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*CreateIndexes) Encode ¶
func (ci *CreateIndexes) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*CreateIndexes) Err ¶
func (ci *CreateIndexes) Err() error
Err returns the error set on this command.
func (*CreateIndexes) Result ¶
func (ci *CreateIndexes) Result() (result.CreateIndexes, error)
Result returns the result of a decoded wire message and server description.
func (*CreateIndexes) RoundTrip ¶
func (ci *CreateIndexes) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (result.CreateIndexes, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type Cursor ¶
type Cursor interface { // Get the ID of the cursor. ID() int64 // Get the next result from the cursor. // Returns true if there were no errors and there is a next result. Next(context.Context) bool // Decode the next document into the provided object according to the // rules of the bson package. Decode(interface{}) error // Returns the next document as a bson.Reader. The user must copy the // bytes to retain them. DecodeBytes() (bson.Reader, error) // Returns the error status of the cursor Err() error // Close the cursor. Close(context.Context) error }
Cursor instances iterate a stream of documents. Each document is decoded into the result according to the rules of the bson package.
A typical usage of the Cursor interface would be:
var cur Cursor ctx := context.Background() defer cur.Close(ctx) for cur.Next(ctx) { elem := bson.NewDocument() if err := cur.Decode(elem); err != nil { log.Fatal(err) } // do something with elem.... } if err := cur.Err(); err != nil { log.Fatal(err) }
type CursorBuilder ¶
type CursorBuilder interface {
BuildCursor(bson.Reader, *session.Client, *session.ClusterClock, ...option.CursorOptioner) (Cursor, error)
}
CursorBuilder is a type that can build a Cursor.
type Delete ¶
type Delete struct { NS Namespace Deletes []*bson.Document Opts []option.DeleteOptioner WriteConcern *writeconcern.WriteConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
Delete represents the delete command.
The delete command executes a delete with a given set of delete documents and options.
func (*Delete) Decode ¶
func (d *Delete) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Delete
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*Delete) Encode ¶
func (d *Delete) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*Delete) RoundTrip ¶
func (d *Delete) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (result.Delete, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type Distinct ¶
type Distinct struct { NS Namespace Field string Query *bson.Document Opts []option.DistinctOptioner ReadPref *readpref.ReadPref ReadConcern *readconcern.ReadConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
Distinct represents the disctinct command.
The distinct command returns the distinct values for a specified field across a single collection.
func (*Distinct) Decode ¶
func (d *Distinct) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Distinct
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*Distinct) Encode ¶
func (d *Distinct) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*Distinct) Result ¶
Result returns the result of a decoded wire message and server description.
func (*Distinct) RoundTrip ¶
func (d *Distinct) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (result.Distinct, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type DropCollection ¶
type DropCollection struct { DB string Collection string WriteConcern *writeconcern.WriteConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
DropCollection represents the drop command.
The dropCollections command drops collection for a database.
func (*DropCollection) Decode ¶
func (dc *DropCollection) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *DropCollection
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*DropCollection) Encode ¶
func (dc *DropCollection) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*DropCollection) Err ¶
func (dc *DropCollection) Err() error
Err returns the error set on this command.
func (*DropCollection) Result ¶
func (dc *DropCollection) Result() (bson.Reader, error)
Result returns the result of a decoded wire message and server description.
func (*DropCollection) RoundTrip ¶
func (dc *DropCollection) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (bson.Reader, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type DropDatabase ¶
type DropDatabase struct { DB string WriteConcern *writeconcern.WriteConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
DropDatabase represents the DropDatabase command.
The DropDatabases command drops database.
func (*DropDatabase) Decode ¶
func (dd *DropDatabase) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *DropDatabase
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*DropDatabase) Encode ¶
func (dd *DropDatabase) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*DropDatabase) Err ¶
func (dd *DropDatabase) Err() error
Err returns the error set on this command.
func (*DropDatabase) Result ¶
func (dd *DropDatabase) Result() (bson.Reader, error)
Result returns the result of a decoded wire message and server description.
func (*DropDatabase) RoundTrip ¶
func (dd *DropDatabase) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (bson.Reader, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type DropIndexes ¶
type DropIndexes struct { NS Namespace Index string Opts []option.DropIndexesOptioner WriteConcern *writeconcern.WriteConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
DropIndexes represents the dropIndexes command.
The dropIndexes command drops indexes for a namespace.
func (*DropIndexes) Decode ¶
func (di *DropIndexes) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *DropIndexes
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*DropIndexes) Encode ¶
func (di *DropIndexes) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*DropIndexes) Err ¶
func (di *DropIndexes) Err() error
Err returns the error set on this command.
func (*DropIndexes) Result ¶
func (di *DropIndexes) Result() (bson.Reader, error)
Result returns the result of a decoded wire message and server description.
func (*DropIndexes) RoundTrip ¶
func (di *DropIndexes) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (bson.Reader, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type EndSessions ¶
type EndSessions struct { Clock *session.ClusterClock SessionIDs []*bson.Document // contains filtered or unexported fields }
EndSessions represents an endSessions command.
func (*EndSessions) Decode ¶
func (es *EndSessions) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *EndSessions
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*EndSessions) Encode ¶
func (es *EndSessions) Encode(desc description.SelectedServer) ([]wiremessage.WireMessage, error)
Encode will encode this command into a series of wire messages for the given server description.
func (*EndSessions) Result ¶
func (es *EndSessions) Result() ([]result.EndSessions, []error)
Result returns the results of the decoded wire messages.
func (*EndSessions) RoundTrip ¶
func (es *EndSessions) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) ([]result.EndSessions, []error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter
type Find ¶
type Find struct { NS Namespace Filter *bson.Document Opts []option.FindOptioner ReadPref *readpref.ReadPref ReadConcern *readconcern.ReadConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
Find represents the find command.
The find command finds documents within a collection that match a filter.
func (*Find) Decode ¶
func (f *Find) Decode(desc description.SelectedServer, cb CursorBuilder, wm wiremessage.WireMessage) *Find
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*Find) Encode ¶
func (f *Find) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*Find) RoundTrip ¶
func (f *Find) RoundTrip(ctx context.Context, desc description.SelectedServer, cb CursorBuilder, rw wiremessage.ReadWriter) (Cursor, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type FindOneAndDelete ¶
type FindOneAndDelete struct { NS Namespace Query *bson.Document Opts []option.FindOneAndDeleteOptioner WriteConcern *writeconcern.WriteConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
FindOneAndDelete represents the findOneAndDelete operation.
The findOneAndDelete command deletes a single document that matches a query and returns it.
func (*FindOneAndDelete) Decode ¶
func (f *FindOneAndDelete) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *FindOneAndDelete
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*FindOneAndDelete) Encode ¶
func (f *FindOneAndDelete) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*FindOneAndDelete) Err ¶
func (f *FindOneAndDelete) Err() error
Err returns the error set on this command.
func (*FindOneAndDelete) Result ¶
func (f *FindOneAndDelete) Result() (result.FindAndModify, error)
Result returns the result of a decoded wire message and server description.
func (*FindOneAndDelete) RoundTrip ¶
func (f *FindOneAndDelete) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (result.FindAndModify, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type FindOneAndReplace ¶
type FindOneAndReplace struct { NS Namespace Query *bson.Document Replacement *bson.Document Opts []option.FindOneAndReplaceOptioner WriteConcern *writeconcern.WriteConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
FindOneAndReplace represents the findOneAndReplace operation.
The findOneAndReplace command modifies and returns a single document.
func (*FindOneAndReplace) Decode ¶
func (f *FindOneAndReplace) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *FindOneAndReplace
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*FindOneAndReplace) Encode ¶
func (f *FindOneAndReplace) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*FindOneAndReplace) Err ¶
func (f *FindOneAndReplace) Err() error
Err returns the error set on this command.
func (*FindOneAndReplace) Result ¶
func (f *FindOneAndReplace) Result() (result.FindAndModify, error)
Result returns the result of a decoded wire message and server description.
func (*FindOneAndReplace) RoundTrip ¶
func (f *FindOneAndReplace) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (result.FindAndModify, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type FindOneAndUpdate ¶
type FindOneAndUpdate struct { NS Namespace Query *bson.Document Update *bson.Document Opts []option.FindOneAndUpdateOptioner WriteConcern *writeconcern.WriteConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
FindOneAndUpdate represents the findOneAndUpdate operation.
The findOneAndUpdate command modifies and returns a single document.
func (*FindOneAndUpdate) Decode ¶
func (f *FindOneAndUpdate) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *FindOneAndUpdate
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*FindOneAndUpdate) Encode ¶
func (f *FindOneAndUpdate) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*FindOneAndUpdate) Err ¶
func (f *FindOneAndUpdate) Err() error
Err returns the error set on this command.
func (*FindOneAndUpdate) Result ¶
func (f *FindOneAndUpdate) Result() (result.FindAndModify, error)
Result returns the result of a decoded wire message and server description.
func (*FindOneAndUpdate) RoundTrip ¶
func (f *FindOneAndUpdate) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (result.FindAndModify, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type GetLastError ¶
type GetLastError struct { Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
GetLastError represents the getLastError command.
The getLastError command is used for getting the last error from the last command on a connection.
Since GetLastError only makes sense in the context of a single connection, there is no Dispatch method.
func (*GetLastError) Decode ¶
func (gle *GetLastError) Decode(wm wiremessage.WireMessage) *GetLastError
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*GetLastError) Encode ¶
func (gle *GetLastError) Encode() (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*GetLastError) Err ¶
func (gle *GetLastError) Err() error
Err returns the error set on this command.
func (*GetLastError) Result ¶
func (gle *GetLastError) Result() (result.GetLastError, error)
Result returns the result of a decoded wire message and server description.
func (*GetLastError) RoundTrip ¶
func (gle *GetLastError) RoundTrip(ctx context.Context, rw wiremessage.ReadWriter) (result.GetLastError, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type GetMore ¶
type GetMore struct { ID int64 NS Namespace Opts []option.CursorOptioner Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
GetMore represents the getMore command.
The getMore command retrieves additional documents from a cursor.
func (*GetMore) Decode ¶
func (gm *GetMore) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *GetMore
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*GetMore) Encode ¶
func (gm *GetMore) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*GetMore) Result ¶
Result returns the result of a decoded wire message and server description.
func (*GetMore) RoundTrip ¶
func (gm *GetMore) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (bson.Reader, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type Handshake ¶
type Handshake struct { Client *bson.Document Compressors []string // contains filtered or unexported fields }
Handshake represents a generic MongoDB Handshake. It calls isMaster and buildInfo.
The isMaster and buildInfo commands are used to build a server description.
func (*Handshake) Decode ¶
func (h *Handshake) Decode(wm wiremessage.WireMessage) *Handshake
Decode will decode the wire messages. Errors during decoding are deferred until either the Result or Err methods are called.
func (*Handshake) Encode ¶
func (h *Handshake) Encode() (wiremessage.WireMessage, error)
Encode will encode the handshake commands into a wire message containing isMaster
func (*Handshake) Handshake ¶
func (h *Handshake) Handshake(ctx context.Context, addr address.Address, rw wiremessage.ReadWriter) (description.Server, error)
Handshake implements the connection.Handshaker interface. It is identical to the RoundTrip methods on other types in this package. It will execute the isMaster command.
type Insert ¶
type Insert struct { Clock *session.ClusterClock NS Namespace Docs []*bson.Document Opts []option.InsertOptioner WriteConcern *writeconcern.WriteConcern Session *session.Client // contains filtered or unexported fields }
Insert represents the insert command.
The insert command inserts a set of documents into the database.
Since the Insert command does not return any value other than ok or an error, this type has no Err method.
func (*Insert) Decode ¶
func (i *Insert) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Insert
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*Insert) Encode ¶
func (i *Insert) Encode(desc description.SelectedServer) ([]wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*Insert) RoundTrip ¶
func (i *Insert) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (result.Insert, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type IsMaster ¶
type IsMaster struct { Client *bson.Document Compressors []string // contains filtered or unexported fields }
IsMaster represents the isMaster command.
The isMaster command is used for setting up a connection to MongoDB and for monitoring a MongoDB server.
Since IsMaster can only be run on a connection, there is no Dispatch method.
func (*IsMaster) Decode ¶
func (im *IsMaster) Decode(wm wiremessage.WireMessage) *IsMaster
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*IsMaster) Encode ¶
func (im *IsMaster) Encode() (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*IsMaster) Result ¶
Result returns the result of a decoded wire message and server description.
func (*IsMaster) RoundTrip ¶
func (im *IsMaster) RoundTrip(ctx context.Context, rw wiremessage.ReadWriter) (result.IsMaster, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type KillCursors ¶
type KillCursors struct { Clock *session.ClusterClock NS Namespace IDs []int64 // contains filtered or unexported fields }
KillCursors represents the killCursors command.
The killCursors command kills a set of cursors.
func (*KillCursors) Decode ¶
func (kc *KillCursors) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *KillCursors
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*KillCursors) Encode ¶
func (kc *KillCursors) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*KillCursors) Err ¶
func (kc *KillCursors) Err() error
Err returns the error set on this command.
func (*KillCursors) Result ¶
func (kc *KillCursors) Result() (result.KillCursors, error)
Result returns the result of a decoded wire message and server description.
func (*KillCursors) RoundTrip ¶
func (kc *KillCursors) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (result.KillCursors, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type ListCollections ¶
type ListCollections struct { Clock *session.ClusterClock DB string Filter *bson.Document Opts []option.ListCollectionsOptioner ReadPref *readpref.ReadPref Session *session.Client // contains filtered or unexported fields }
ListCollections represents the listCollections command.
The listCollections command lists the collections in a database.
func (*ListCollections) Decode ¶
func (lc *ListCollections) Decode(desc description.SelectedServer, cb CursorBuilder, wm wiremessage.WireMessage) *ListCollections
Decode will decode the wire message using the provided server description. Errors during decolcng are deferred until either the Result or Err methods are called.
func (*ListCollections) Encode ¶
func (lc *ListCollections) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*ListCollections) Err ¶
func (lc *ListCollections) Err() error
Err returns the error set on this command.
func (*ListCollections) Result ¶
func (lc *ListCollections) Result() (Cursor, error)
Result returns the result of a decoded wire message and server description.
func (*ListCollections) RoundTrip ¶
func (lc *ListCollections) RoundTrip(ctx context.Context, desc description.SelectedServer, cb CursorBuilder, rw wiremessage.ReadWriter) (Cursor, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type ListDatabases ¶
type ListDatabases struct { Clock *session.ClusterClock Filter *bson.Document Opts []option.ListDatabasesOptioner Session *session.Client // contains filtered or unexported fields }
ListDatabases represents the listDatabases command.
The listDatabases command lists the databases in a MongoDB deployment.
func (*ListDatabases) Decode ¶
func (ld *ListDatabases) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *ListDatabases
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*ListDatabases) Encode ¶
func (ld *ListDatabases) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*ListDatabases) Err ¶
func (ld *ListDatabases) Err() error
Err returns the error set on this command.
func (*ListDatabases) Result ¶
func (ld *ListDatabases) Result() (result.ListDatabases, error)
Result returns the result of a decoded wire message and server description.
func (*ListDatabases) RoundTrip ¶
func (ld *ListDatabases) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (result.ListDatabases, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type ListIndexes ¶
type ListIndexes struct { Clock *session.ClusterClock NS Namespace Opts []option.ListIndexesOptioner Session *session.Client // contains filtered or unexported fields }
ListIndexes represents the listIndexes command.
The listIndexes command lists the indexes for a namespace.
func (*ListIndexes) Decode ¶
func (li *ListIndexes) Decode(desc description.SelectedServer, cb CursorBuilder, wm wiremessage.WireMessage) *ListIndexes
Decode will decode the wire message using the provided server description. Errors during decoling are deferred until either the Result or Err methods are called.
func (*ListIndexes) Encode ¶
func (li *ListIndexes) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*ListIndexes) Err ¶
func (li *ListIndexes) Err() error
Err returns the error set on this command.
func (*ListIndexes) Result ¶
func (li *ListIndexes) Result() (Cursor, error)
Result returns the result of a decoded wire message and server description.
func (*ListIndexes) RoundTrip ¶
func (li *ListIndexes) RoundTrip(ctx context.Context, desc description.SelectedServer, cb CursorBuilder, rw wiremessage.ReadWriter) (Cursor, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type Namespace ¶
Namespace encapsulates a database and collection name, which together uniquely identifies a collection within a MongoDB cluster.
func NewNamespace ¶
NewNamespace returns a new Namespace for the given database and collection.
func ParseNamespace ¶
ParseNamespace parses a namespace string into a Namespace.
The namespace string must contain at least one ".", the first of which is the separator between the database and collection names. If not, the default (invalid) Namespace is returned.
type QueryFailureError ¶
QueryFailureError is an error representing a command failure as a document.
func (QueryFailureError) Error ¶
func (e QueryFailureError) Error() string
Error implements the error interface.
type Read ¶
type Read struct { DB string Command *bson.Document ReadPref *readpref.ReadPref ReadConcern *readconcern.ReadConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
Read represents a generic database read command.
func (*Read) Decode ¶
func (r *Read) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Read
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*Read) Encode ¶
func (r *Read) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*Read) RoundTrip ¶
func (r *Read) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (bson.Reader, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type ResponseError ¶
ResponseError is an error parsing the response to a command.
func NewCommandResponseError ¶
func NewCommandResponseError(msg string, err error) ResponseError
NewCommandResponseError creates a CommandResponseError.
func (ResponseError) Error ¶
func (e ResponseError) Error() string
Error implements the error interface.
type StartSession ¶
type StartSession struct { Clock *session.ClusterClock // contains filtered or unexported fields }
StartSession represents a startSession command
func (*StartSession) Decode ¶
func (ss *StartSession) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *StartSession
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*StartSession) Encode ¶
func (ss *StartSession) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wiremessage for the given server description.
func (*StartSession) Err ¶
func (ss *StartSession) Err() error
Err returns the error set on this command
func (*StartSession) Result ¶
func (ss *StartSession) Result() (result.StartSession, error)
Result returns the result of a decoded wire message and server description.
func (*StartSession) RoundTrip ¶
func (ss *StartSession) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (result.StartSession, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter
type Update ¶
type Update struct { Clock *session.ClusterClock NS Namespace Docs []*bson.Document Opts []option.UpdateOptioner WriteConcern *writeconcern.WriteConcern Session *session.Client // contains filtered or unexported fields }
Update represents the update command.
The update command updates a set of documents with the database.
func (*Update) Decode ¶
func (u *Update) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Update
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*Update) Encode ¶
func (u *Update) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*Update) RoundTrip ¶
func (u *Update) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (result.Update, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriter.
type Write ¶
type Write struct { DB string Command *bson.Document WriteConcern *writeconcern.WriteConcern Clock *session.ClusterClock Session *session.Client // contains filtered or unexported fields }
Write represents a generic write database command. This can be used to send arbitrary write commands to the database.
func (*Write) Decode ¶
func (w *Write) Decode(desc description.SelectedServer, wm wiremessage.WireMessage) *Write
Decode will decode the wire message using the provided server description. Errors during decoding are deferred until either the Result or Err methods are called.
func (*Write) Encode ¶
func (w *Write) Encode(desc description.SelectedServer) (wiremessage.WireMessage, error)
Encode will encode this command into a wire message for the given server description.
func (*Write) RoundTrip ¶
func (w *Write) RoundTrip(ctx context.Context, desc description.SelectedServer, rw wiremessage.ReadWriter) (bson.Reader, error)
RoundTrip handles the execution of this command using the provided wiremessage.ReadWriteCloser.
Source Files ¶
- aggregate.go
- buildinfo.go
- command.go
- count.go
- create_indexes.go
- cursor.go
- delete.go
- distinct.go
- doc.go
- drop_collection.go
- drop_database.go
- drop_indexes.go
- end_sessions.go
- errors.go
- find.go
- find_and_modify.go
- find_one_delete.go
- find_one_replace.go
- find_one_update.go
- get_more.go
- getlasterror.go
- handshake.go
- insert.go
- ismaster.go
- kill_cursors.go
- list_collections.go
- list_databases.go
- list_indexes.go
- namespace.go
- opmsg.go
- opreply.go
- read.go
- start_session.go
- update.go
- write.go