mongo

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package mongo implements the interface for MongoDB.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mongo

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

Mongo implements a connection to a MongoDB database.

func New

func New(uri string) (*Mongo, error)

New returns a Mongo client connection to the specified MongoDB database uri.

func (*Mongo) AddAddress

func (m *Mongo) AddAddress(a store.Address, net string) ([]byte, error)

AddAddress saves an address if the address does not already exist.

func (*Mongo) CloseMongo

func (m *Mongo) CloseMongo() error

CloseMongo will close a database connection. Must be called at termination time.

func (*Mongo) DeleteExplorer

func (m *Mongo) DeleteExplorer(net string) (err error)

DeleteExplorer deletes from db the NetExplorer for the indicated blockchain.

func (*Mongo) GetAddresses

func (m *Mongo) GetAddresses(net []string) ([]store.ListenedAddresses, error)

GetAddresses returns the addresses or objects monitored for the network or blockchains indicated in the net slice.

func (*Mongo) LoadExplorer

func (m *Mongo) LoadExplorer(net string) (ne store.NetExplorer, err error)

LoadExplorer loads from db the NetExplorer type for the indicated blockchain.

func (*Mongo) RemoveAddress

func (m *Mongo) RemoveAddress(a store.Address, net string) error

RemoveAddress deletes an address from the database.

func (*Mongo) SaveExplorer

func (m *Mongo) SaveExplorer(net string, ne store.NetExplorer) (err error)

SaveExplorer saves to db the NetExplorer for the indicated blockchain.

type MongoAddress

type MongoAddress struct {
	ID   primitive.ObjectID `json:"_id" bson:"_id"`
	Name string             `json:"name,omitempty" bson:"name,omitempty"`
	Addr string             `json:"address" bson:"address"`
}

MongoAddress implements a store address to MongoDB.

func (MongoAddress) Address

func (a MongoAddress) Address() store.Address

Address converts a MongoAddress to store.Address type.

Jump to

Keyboard shortcuts

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