mongox

package
v0.0.0-...-37ffb23 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultURI = "mongodb://127.0.0.1:27017"

Variables

This section is empty.

Functions

func FieldTagName

func FieldTagName(field reflect.StructField) string

func WithAuth

func WithAuth(username, password string) func(opts *Options)

Types

type Client

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

func NewClient

func NewClient(uri string, database string, opts ...func(opts *Options)) *Client

func (*Client) Collection

func (p *Client) Collection(name string) *Collection

func (*Client) Ping

func (p *Client) Ping() error

type Collection

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

func (*Collection) DeleteOne

func (p *Collection) DeleteOne(filter any) (bool, error)

func (*Collection) Find

func (p *Collection) Find(filter any, results any, fields ...string) error

Find finds documents by filter and returns the results. The results must be a pointer to a slice.

func (*Collection) FindOne

func (p *Collection) FindOne(id string, out any, fields ...string) error

func (*Collection) Insert

func (p *Collection) Insert(document any) (string, error)

func (*Collection) InsertMany

func (p *Collection) InsertMany(documents ...any) ([]string, error)

func (*Collection) RawFind

func (p *Collection) RawFind(filter bson.M, results any, opts *options.FindOptions) error

func (*Collection) Update

func (p *Collection) Update(id string, document any) error

func (*Collection) UpdateInsert

func (p *Collection) UpdateInsert(filter, update any) (string, error)

func (*Collection) UpdateMany

func (p *Collection) UpdateMany(filter, update bson.M) error

type Options

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

Jump to

Keyboard shortcuts

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