mongoclient

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Placeholder collection name for explicit database creation.
	PlaceholderCollectionName = "__terraform_provider_mongodb"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

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

func (*Collection) Client

func (c *Collection) Client() *MongoClient

func (*Collection) Database

func (c *Collection) Database() *Database

func (*Collection) DeleteByID

func (c *Collection) DeleteByID(id string) error

func (*Collection) Drop

func (c *Collection) Drop() error

func (*Collection) EnsureExistance

func (c *Collection) EnsureExistance() error

func (*Collection) Exists

func (c *Collection) Exists() (bool, error)

func (*Collection) Find added in v0.4.0

func (c *Collection) Find(filter Document) (Documents, error)

func (*Collection) FindById

func (c *Collection) FindById(id string, opts *FindByIdOptions) (Document, error)

func (*Collection) Index

func (c *Collection) Index(name string) *Index

func (*Collection) IndexFromField

func (c *Collection) IndexFromField(field string, direction int, unique bool) *Index

func (*Collection) InsertOne

func (c *Collection) InsertOne(document Document) (string, error)

func (*Collection) IsEmpty

func (c *Collection) IsEmpty() (bool, error)

func (*Collection) Name

func (c *Collection) Name() string

func (*Collection) UpdateByID

func (c *Collection) UpdateByID(id string, update Document) error

func (*Collection) WithContext

func (c *Collection) WithContext(ctx context.Context) *Collection

func (*Collection) WithLogger

func (c *Collection) WithLogger(logger *zap.Logger) *Collection

type Config

type Config struct {
	URI string
}

type Database

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

func (*Database) Client

func (d *Database) Client() *MongoClient

func (*Database) Collection

func (d *Database) Collection(name string) *Collection

func (*Database) Drop

func (d *Database) Drop() error

func (*Database) EnsureExistance

func (d *Database) EnsureExistance() error

func (*Database) Exists

func (d *Database) Exists() (bool, error)

func (*Database) IsEmpty

func (d *Database) IsEmpty() (bool, error)

func (*Database) Name

func (d *Database) Name() string

func (*Database) WithContext

func (d *Database) WithContext(ctx context.Context) *Database

func (*Database) WithLogger

func (d *Database) WithLogger(logger *zap.Logger) *Database

type Document

type Document map[string]interface{}

func (*Document) ToBson added in v0.2.0

func (d *Document) ToBson() (bson.D, error)

Converts extended json to bson.

func (*Document) ToEJson added in v0.2.0

func (d *Document) ToEJson() (string, error)

type Documents

type Documents []Document

type FindByIdOptions

type FindByIdOptions struct {
	IncludeId bool
}

type Index

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

func (*Index) Client

func (i *Index) Client() *MongoClient

func (*Index) Collection

func (i *Index) Collection() *Collection

func (*Index) Database

func (i *Index) Database() *Database

func (*Index) Direction

func (i *Index) Direction() int

func (*Index) Drop

func (i *Index) Drop() error

func (*Index) EnsureExistance

func (i *Index) EnsureExistance() error

func (*Index) Exists

func (i *Index) Exists() (bool, error)

func (*Index) Field

func (i *Index) Field() string

func (*Index) GetSpec

func (i *Index) GetSpec() (*SanitizedIndexSpec, error)

func (*Index) Hydrate

func (i *Index) Hydrate(spec *SanitizedIndexSpec) *Index

func (*Index) Name

func (i *Index) Name() string

func (*Index) Unique

func (i *Index) Unique() bool

func (*Index) WithContext

func (i *Index) WithContext(ctx context.Context) *Index

type MongoClient

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

func FromURI

func FromURI(uri string) *MongoClient

func New

func New(ctx context.Context, config *Config) *MongoClient

func (*MongoClient) Client

func (c *MongoClient) Client() *mongo.Client

func (*MongoClient) Connect

func (c *MongoClient) Connect() error

func (*MongoClient) Database

func (c *MongoClient) Database(name string) *Database

func (*MongoClient) Disconnect

func (c *MongoClient) Disconnect()

func (*MongoClient) IsConnected

func (c *MongoClient) IsConnected() bool

func (*MongoClient) Run

func (c *MongoClient) Run(callback func(client *MongoClient, err error))

func (*MongoClient) WithContext

func (c *MongoClient) WithContext(ctx context.Context) *MongoClient

func (*MongoClient) WithLogger

func (c *MongoClient) WithLogger(logger *zap.Logger) *MongoClient

type SanitizedIndexSpec

type SanitizedIndexSpec struct {
	Name      string
	Field     string
	Direction int
	Unique    bool
}

Jump to

Keyboard shortcuts

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