mongodb

package
v0.0.0-...-db4d63e Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionCreate = "create"
	ActionUpdate = "update"
	ActionDelete = "delete"
	ActionInsert = "insert"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkRequest

type BulkRequest struct {
	Action     string
	Database   string
	Collection string
	ID         string
	Filter     map[string]interface{}
	Data       map[string]interface{}
}

type BulkResponse

type BulkResponse struct {
	Code   int
	Took   int  `json:"took"`
	Errors bool `json:"errors"`

	Items []map[string]*BulkResponseItem `json:"items"`
}

type BulkResponseItem

type BulkResponseItem struct {
	Database   string `json:"_database"`
	Collection string `json:"_collection"`
	ID         string `json:"_id"`
	Status     int    `json:"status"`
	Found      bool   `json:"found"`
}

type Client

type Client struct {
	Addr     string
	Username string
	Password string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(conf *ClientConfig) (*Client, error)

func (*Client) Bulk

func (c *Client) Bulk(items []*BulkRequest) error

func (*Client) Delete

func (c *Client) Delete(database string, collection string, id string) error

Delete deletes the item by id.

func (*Client) DeleteDB

func (c *Client) DeleteDB(database string) error

func (*Client) Exists

func (c *Client) Exists(database string, collection string, id string) (bool, error)

Exists checks whether id exists or not.

func (*Client) Get

func (c *Client) Get(database string, collection string, id string) (*Response, error)

func (*Client) Update

func (c *Client) Update(database string, collection string, id string, data map[string]interface{}) error

Update creates or updates the data

type ClientConfig

type ClientConfig struct {
	Addr     string
	Username string
	Password string
}

type Response

type Response struct {
	Code int
	ResponseItem
}

type ResponseItem

type ResponseItem struct {
	ID         string                 `json:"_id"`
	Database   string                 `json:"_database"`
	Collection string                 `json:"_collection"`
	Found      bool                   `json:"found"`
	Source     map[string]interface{} `json:"_source"`
}

Jump to

Keyboard shortcuts

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