Documentation
¶
Index ¶
- Constants
- type BuildConfig
- type Command
- type Config
- type Query
- func (q *Query) Collection() string
- func (q *Query) Conditions() []bson.Document
- func (q *Query) Database() string
- func (q *Query) Documents() []bson.Document
- func (q *Query) FullCollectionName() string
- func (q *Query) HasConditions() bool
- func (q *Query) Limit() int
- func (q *Query) Operator() string
- func (q *Query) ParseMsg(msg *protocol.Msg) error
- func (q *Query) ParseQuery(msg *protocol.Query) error
- func (q *Query) Type() string
- type Response
- func NewBadResponse() *Response
- func NewBuildInfoResponseWithConfig(config Config) (*Response, error)
- func NewDefaultBuildInfoResponse() (*Response, error)
- func NewDefaultIsMasterResponse() (*Response, error)
- func NewDefaultLastErrorResponse() (*Response, error)
- func NewIsMasterResponseWithConfig(config ServerConfig) (*Response, error)
- func NewMessageReplyWithParameters(ok bool, n int32) *Response
- func NewOkResponse() *Response
- func NewResponse() *Response
- func NewResponseWithElements(elements map[string]any) (*Response, error)
- func NewResponseWithStatus(status bool) *Response
- func (res *Response) SetCursorDocuments(fullCollectionName string, docs []bson.Document)
- func (res *Response) SetErrorStatus(err error)
- func (res *Response) SetNumberOfAffectedDocuments(n int32)
- func (res *Response) SetNumberOfModifiedDocuments(n int32)
- func (res *Response) SetStatus(flag bool)
- func (res *Response) SetVersion(ver string)
- type ServerConfig
Constants ¶
const ( IsMaster = "ismaster" BuildInfo = "buildinfo" GetLastError = "getlasterror" SASLStart = "saslstart" SASLMechanism = "mechanism" SASLContinue = "saslcontinue" SASLSupportedMechs = "saslSupportedMechs" Hello = "hello" HelloOk = "helloOk" )
const ( DefaultMaxBsonObjectSize = 16 * 1024 * 1024 DefaultMaxMessageSizeBytes = 48000000 DefaultMaxWriteBatchSize = 100000 DefaultLogicalSessionTimeoutMinutes = 30 DefaultMinWireVersion = 0 DefaultMaxWireVersion = 7 )
const ( // CurrentDate sets the value of a field to current date, either as a Date or a Timestamp. CurrentDate = "$currentDate" // Inc increments the value of the field by the specified amount. Inc = "$inc" // Min only updates the field if the specified value is less than the existing field value. Min = "$min" // Max only updates the field if the specified value is greater than the existing field value. Max = "$max" // Mul multiplies the value of the field by the specified amount. Mul = "$mul" // Rename renames a field. Rename = "$rename" // Set ets the value of a field in a document. Set = "$set" // SetOnInsert sets the value of a field if an update results in an insert of a document. Has no effect on update operations that modify existing documents. SetOnInsert = "$setOnInsert" // Unset removes the specified field from a document. Unset = "$unset" )
const ( Delete = "delete" Insert = "insert" Find = "find" Update = "update" LsID = "lsid" ID = "id" Binary = "$binary" Base64 = "base64" SubType = "subType" DB = "$db" Filter = "filter" Documents = "documents" KillCursors = "killCursors" )
const ( // DefaultCompatibleVersion = "4.0.12". // DefaultCompatibleVersion = "3.6.4". DefaultCompatibleVersion = "3.4.22" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildConfig ¶
type BuildConfig interface { // Version should return a software version. Version() string }
BuildConfig represents a limit configurations for 'buildInfo' command.
type Command ¶
type Command struct { IsAdmin bool Elements []bson.Element // contains filtered or unexported fields }
Command represents a query command of MongoDB database command.
func NewCommandWithDocument ¶
NewCommandWithDocument returns a new command instance with the specified BSON document.
func NewCommandWithMsg ¶
NewCommandWithMsg returns a new command instance with the specified BSON document.
func NewCommandWithQuery ¶
NewCommandWithQuery returns a new command instance with the specified BSON document.
func (*Command) IsAdminCommand ¶
IsAdminCommand returns true when it is a admin command, otherwise false.
type Config ¶
type Config interface { ServerConfig BuildConfig }
Config represents all configurations for MongoDB.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query represents a message query.
func NewQueryWithMessage ¶
NewQueryWithMessage returns a new query with the specified OP_MSG.
func NewQueryWithQuery ¶
NewQueryWithQuery returns a new query with the specified OP_QUERY.
func (*Query) Collection ¶
Collection returns the collection name.
func (*Query) Conditions ¶
Conditions returns the search conditions.
func (*Query) FullCollectionName ¶ added in v1.2.0
FullCollectionName returns the full collection name.
func (*Query) HasConditions ¶ added in v0.9.4
HasConditions returns true if the query has conditions.
func (*Query) ParseQuery ¶
ParseQuery parses the specified OP_MSG.
type Response ¶
type Response struct {
*bson.Dictionary
}
Response represents response elements.
func NewBuildInfoResponseWithConfig ¶
NewBuildInfoResponseWithConfig returns a response instance with the specified configuration.
func NewDefaultBuildInfoResponse ¶
NewDefaultBuildInfoResponse returns a default response instance.
func NewDefaultIsMasterResponse ¶
NewDefaultIsMasterResponse returns a default response instance.
func NewDefaultLastErrorResponse ¶
NewDefaultLastErrorResponse returns a default response instance.
func NewIsMasterResponseWithConfig ¶
func NewIsMasterResponseWithConfig(config ServerConfig) (*Response, error)
NewIsMasterResponseWithConfig returns a response instance with the specified configuration.
func NewMessageReplyWithParameters ¶
NewMessageReplyWithParameters returns a message response instance.
func NewResponseWithElements ¶
NewResponseWithElements returns a new response instance.
func NewResponseWithStatus ¶
NewResponseWithStatus returns a simple response which has only a status element.
func (*Response) SetCursorDocuments ¶
SetCursorDocuments sets a resultset.
func (*Response) SetErrorStatus ¶ added in v0.9.1
SetErrorStatus sets an int32 response result.
func (*Response) SetNumberOfAffectedDocuments ¶
SetNumberOfAffectedDocuments sets a number of affected documents.
func (*Response) SetNumberOfModifiedDocuments ¶
SetNumberOfModifiedDocuments sets a number of modified documents.
func (*Response) SetVersion ¶
SetVersion sets a version string and array of the specified version string.
type ServerConfig ¶
type ServerConfig interface { // IsMaster should return true when the instance is running as master, otherwise false IsMaster() bool // MaxBsonObjectSize should return a max limitation value of BSON object size. MaxBsonObjectSize() int32 // MaxMessageSizeBytes should return a max limitation value of message size. MaxMessageSizeBytes() int32 // MaxWriteBatchSize should return a max limitation value of write batch size. MaxWriteBatchSize() int32 // LogicalSessionTimeoutMinutes should return a settion timeout value. LogicalSessionTimeoutMinutes() int32 // MinWireVersion should return a min supported version. MinWireVersion() int32 // MaxWireVersion should return a max supported version. MaxWireVersion() int32 // IsReadOnly should return true when the instance does not support write operations. IsReadOnly() bool // Compressions should return supported compress strings. Compressions() []string }
ServerConfig represents a limit configurations for 'isMaseter' command.