mongodb

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluginMongoDB = storageTY.TypeMongoDB

	DefaultCollectionPrefix = "mc_"
)

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, config cmap.CustomMap) (storageTY.Plugin, error)

New mongodb

Types

type Client

type Client struct {
	Client *mongoDriver.Client
	Config Config
	// contains filtered or unexported fields
}

Client of the mongo db

func (*Client) ClearDatabase

func (c *Client) ClearDatabase() error

ClearDatabase removes all the data from the database

func (*Client) Close

func (c *Client) Close() error

Close the connection

func (*Client) Count

func (c *Client) Count(entityName string, filters []storageTY.Filter) (int64, error)

Count returns available documents count from a collection

func (*Client) Delete

func (c *Client) Delete(entityName string, filters []storageTY.Filter) (int64, error)

Delete by filter

func (*Client) DoStartupImport

func (s *Client) DoStartupImport() (bool, string, string)

DoStartupImport returns the needs, files location, and file format

func (*Client) Find

func (c *Client) Find(entityName string, out interface{}, filters []storageTY.Filter, pagination *storageTY.Pagination) (*storageTY.Result, error)

Find returns data

func (*Client) FindOne

func (c *Client) FindOne(entityName string, out interface{}, filters []storageTY.Filter) error

FindOne returns data

func (*Client) Insert

func (c *Client) Insert(entityName string, data interface{}) error

Insert the entity

func (*Client) Name

func (s *Client) Name() string

func (*Client) Pause

func (c *Client) Pause() error

Pause the database to perform import like jobs

func (*Client) Ping

func (c *Client) Ping() error

Ping to the target database

func (*Client) Resume

func (c *Client) Resume() error

Resume the database if Paused

func (*Client) Update

func (c *Client) Update(entityName string, data interface{}, filters []storageTY.Filter) error

Update the entity

func (*Client) Upsert

func (c *Client) Upsert(entityName string, data interface{}, filters []storageTY.Filter) error

Upsert date into database

type Config

type Config struct {
	Name             string `yaml:"name"`
	Database         string `yaml:"database"`
	URI              string `yaml:"uri"`
	CollectionPrefix string `yaml:"collection_prefix"`
}

Config of the database

Jump to

Keyboard shortcuts

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