database

package
v0.0.0-...-a198538 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	*mongo.Client
}

Connection is a mongo client

func Connect

func Connect(ctx context.Context) (*Connection, error)

Connect establishes a connection to the mongo db

func (*Connection) ClearState

func (c *Connection) ClearState() error

ClearState will clear the state (drop collection)

func (*Connection) CountCollectionDocs

func (c *Connection) CountCollectionDocs(collectionName string, filter bson.M) (int64, error)

CountCollectionDocs returns the number of records in a given collection

func (*Connection) GetAttestationState

func (c *Connection) GetAttestationState(urnHash string) (*attestation.State, error)

GetAttestationState gets a single document for a state collection

func (*Connection) GetDocs

func (c *Connection) GetDocs(collectionName string, limit int64, skip int64, filter bson.M) ([]bmap.Tx, error)

GetDocs gets a number of documents for a given collection

func (*Connection) GetIdentityState

func (c *Connection) GetIdentityState(idKey string) (*identity.State, error)

GetIdentityState gets a single document for a state collection

func (*Connection) GetIdentityStateByTxID

func (c *Connection) GetIdentityStateByTxID(txid string) (*identity.State, error)

GetIdentityStateByTxID gets a single document for a state collection by txid

func (*Connection) GetIdentityStateFromAddress

func (c *Connection) GetIdentityStateFromAddress(address string) (*identity.State, error)

GetIdentityStateFromAddress gets a single document for a state collection

func (*Connection) GetStateDocs

func (c *Connection) GetStateDocs(collectionName string, limit int64, skip int64, filter bson.M) ([]bson.M, error)

GetStateDocs gets a number of documents for a given state collection

func (*Connection) InsertOne

func (c *Connection) InsertOne(collectionName string, data bson.M) (interface{}, error)

InsertOne connects and inserts the provided data into the provided collection

func (*Connection) Update

func (c *Connection) Update(collectionName string, filter interface{}, update bson.M) (interface{}, error)

Update connects and updates the provided data into the provided collection NOTE: This function can update multiple records if the filter is not restrictive

func (*Connection) Upsert

func (c *Connection) Upsert(collectionName string, filter interface{}, update bson.M) (interface{}, error)

Upsert connects and updates the provided data into the provided collection given the filter

func (*Connection) UpsertOne

func (c *Connection) UpsertOne(collectionName string, filter interface{}, data bson.M) (interface{}, error)

UpsertOne connects and updates the provided data into the provided collection given the filter

Jump to

Keyboard shortcuts

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