mongo

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObjectID = "_id"
)

Variables

View Source
var ErrNotSupported = errors.New("not supported")

Functions

func DecodeBSONDocument

func DecodeBSONDocument(obj document.Object) (bson.Document, error)

DecodeBSONDocument returns the decorded BSON object from the specified object.

func DecodeBSONValue

func DecodeBSONValue(obj any) (*bsoncore.Value, error)

func EncodeBSONDocument

func EncodeBSONDocument(bsonDoc bson.Document) (document.Object, error)

func EncodeBSONValue

func EncodeBSONValue(bsonVal bsoncore.Value) (any, error)

func LookupBSONDocumentObjectID

func LookupBSONDocumentObjectID(bsonDoc bson.Document) (any, error)

func UpdateBSONDocument

func UpdateBSONDocument(doc bson.Document, updateDocs []bson.Document) (bson.Document, error)

Types

type BSONDecoder

type BSONDecoder struct {
}

BSONDecoder represents a decoder.

func NewBSONDecoder

func NewBSONDecoder() *BSONDecoder

NewBSONDecoder returns a new CBOR erializer instance.

func (*BSONDecoder) DecodeBSON

func (s *BSONDecoder) DecodeBSON(obj document.Object) (bson.Document, error)

DecodeBSON returns the decorded BSON object from the specified object.

type BSONEncoder

type BSONEncoder struct {
}

BSONEncoder represents a BSON encoder.

func NewBSONEncoder

func NewBSONEncoder() *BSONEncoder

NewBSONEncoder returns a new BSON encoder instance.

func (*BSONEncoder) EncodeBSON

func (s *BSONEncoder) EncodeBSON(bsonDoc bson.Document) (document.Object, error)

EncodeBSON encodes the specified BSON object to a document object.

type Coder added in v0.9.0

type Coder struct {
	*BSONDecoder
	*BSONEncoder
}

A Coder includes a BSON decoder and encoder.

func NewCoder added in v0.9.0

func NewCoder() *Coder

NewCoder returns a new BSON coder instance.

type Service

type Service struct {
	*mongo.Server
	*query.BaseService
	*Coder
}

func NewService

func NewService() *Service

NewService returns a MongoDB service instance.

func (*Service) Delete

func (service *Service) Delete(conn *mongo.Conn, q *mongo.Query) (int32, error)

Delete hadles OP_DELETE and 'delete' query of OP_MSG or OP_QUERY.

func (*Service) Find

func (service *Service) Find(conn *mongo.Conn, q *mongo.Query) ([]bson.Document, error)

Find hadles 'find' query of OP_MSG or OP_QUERY.

func (*Service) GetDatabase

func (service *Service) GetDatabase(ctx context.Context, name string) (store.Database, error)

GetDatabase returns the database with the specified name.

func (*Service) Insert

func (service *Service) Insert(conn *mongo.Conn, q *mongo.Query) (int32, error)

Insert hadles OP_INSERT and 'insert' query of OP_MSG or OP_QUERY.

func (*Service) MessageReceived

func (service *Service) MessageReceived(msg mongo.OpMessage)

MessageReceived passes a request message from MongoDB client.

func (*Service) MessageRespond

func (service *Service) MessageRespond(msg mongo.OpMessage)

MessageRespond passes a response message from mongo.Server.

func (*Service) ServiceName

func (service *Service) ServiceName() string

ServiceName returns the plug-in service name.

func (*Service) Start added in v1.0.0

func (service *Service) Start() error

Start starts the service.

func (*Service) Stop added in v1.0.0

func (service *Service) Stop() error

Stop stops the service.

func (*Service) Update

func (service *Service) Update(conn *mongo.Conn, q *mongo.Query) (int32, error)

Update hadles OP_UPDATE and 'update' query of OP_MSG or OP_QUERY.

Jump to

Keyboard shortcuts

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