client

package
v3.65.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDocs

func ConfigDocs() docs.FieldSpecs

ConfigDocs returns a documentation field spec for fields within a Config.

Types

type Config

type Config struct {
	URL        string `json:"url" yaml:"url"`
	Database   string `json:"database" yaml:"database"`
	Collection string `json:"collection" yaml:"collection"`
	Username   string `json:"username" yaml:"username"`
	Password   string `json:"password" yaml:"password"`
}

Config is a config struct for a mongo connection

func NewConfig

func NewConfig() Config

NewConfig returns a Config with default values.

func (Config) Client

func (m Config) Client() (*mongo.Client, error)

Client returns a new mongodb client based on the configuration parameters

type JSONMarshalMode

type JSONMarshalMode string

JSONMarshalMode represents the way in which BSON should be marshalled to JSON

const (
	// JSONMarshalModeCanonical Canonical BSON to JSON marshal mode
	JSONMarshalModeCanonical JSONMarshalMode = "canonical"
	// JSONMarshalModeRelaxed Relaxed BSON to JSON marshal mode
	JSONMarshalModeRelaxed JSONMarshalMode = "relaxed"
)

type Operation

type Operation string

Operation represents the operation that will be performed by MongoDB

const (
	// OperationInsertOne Insert One operation
	OperationInsertOne Operation = "insert-one"
	// OperationDeleteOne Delete One operation
	OperationDeleteOne Operation = "delete-one"
	// OperationDeleteMany Delete many operation
	OperationDeleteMany Operation = "delete-many"
	// OperationReplaceOne Replace one operation
	OperationReplaceOne Operation = "replace-one"
	// OperationUpdateOne Update one operation
	OperationUpdateOne Operation = "update-one"
	// OperationFindOne Find one operation
	OperationFindOne Operation = "find-one"
	// OperationInvalid Invalid operation
	OperationInvalid Operation = "invalid"
)

func NewOperation

func NewOperation(op string) Operation

NewOperation converts a string operation to a strongly-typed Operation

type WriteConcern

type WriteConcern struct {
	W        string `json:"w" yaml:"w"`
	J        bool   `json:"j" yaml:"j"`
	WTimeout string `json:"w_timeout" yaml:"w_timeout"`
}

WriteConcern describes a write concern for MongoDB.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL