Documentation ¶
Overview ¶
Package mongodb provides storages of mongodb.
Index ¶
- Constants
- Variables
- func CleanTemporayDatabase(st *Database) error
- func LoadDataFromDoc(b []byte, encs *encoder.Encoders) (bson.Raw, interface{}, error)
- func MergeError(err error) error
- func NewLastManifestDoc(height base.Height, enc encoder.Encoder) (lastManifestDoc, error)
- type BaseDoc
- type BaseDocUnpacker
- type BlockDoc
- type BlockdataMapDoc
- type Client
- func (cl *Client) Add(col string, doc Doc) (interface{}, error)
- func (cl *Client) AddRaw(col string, raw bson.Raw) (interface{}, error)
- func (cl *Client) Bulk(ctx context.Context, col string, models []mongo.WriteModel, order bool) error
- func (cl *Client) Close() error
- func (cl *Client) Collection(col string) *mongo.Collection
- func (cl *Client) Collections() ([]string, error)
- func (cl *Client) CopyCollection(source *Client, fromCol, toCol string) error
- func (cl *Client) Count(ctx context.Context, col string, filter interface{}, ...) (int64, error)
- func (cl *Client) Database(db string) *mongo.Database
- func (cl *Client) Databases(filter interface{}) ([]string, error)
- func (cl *Client) Delete(col string, filter bson.D, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (cl *Client) DropDatabase() error
- func (cl *Client) Exists(col string, filter bson.D) (bool, error)
- func (cl *Client) Find(ctx context.Context, col string, query interface{}, ...) error
- func (cl *Client) GetByFilter(col string, filter bson.D, callback getRecordCallback, ...) error
- func (cl *Client) GetByID(col string, id interface{}, callback getRecordCallback, ...) error
- func (cl *Client) New(db string) (*Client, error)
- func (cl *Client) Raw() *mongo.Client
- func (cl *Client) Set(col string, doc Doc) (interface{}, error)
- func (cl *Client) WithSession(...) (interface{}, error)
- type Database
- func (st *Database) BlockdataMap(height base.Height) (block.BlockdataMap, bool, error)
- func (st *Database) Cache() cache.Cache
- func (st *Database) Clean() error
- func (st *Database) CleanByHeight(height base.Height) error
- func (st *Database) Client() *Client
- func (st *Database) Close() error
- func (st *Database) Copy(source storage.Database) error
- func (st *Database) CreateIndex(col string, models []mongo.IndexModel, prefix string) error
- func (st *Database) Encoder() encoder.Encoder
- func (st *Database) Encoders() *encoder.Encoders
- func (st *Database) HasOperationFact(h valuehash.Hash) (bool, error)
- func (st *Database) HasStagedOperation(h valuehash.Hash) (bool, error)
- func (st *Database) Info(key string) ([]byte, bool, error)
- func (st *Database) Initialize() error
- func (st *Database) LastManifest() (block.Manifest, bool, error)
- func (st *Database) LastVoteproof(stage base.Stage) base.Voteproof
- func (st *Database) LocalBlockdataMapsByHeight(height base.Height, callback func(block.BlockdataMap) (bool, error)) error
- func (st *Database) Manifest(h valuehash.Hash) (block.Manifest, bool, error)
- func (st *Database) ManifestByHeight(height base.Height) (block.Manifest, bool, error)
- func (st *Database) Manifests(load, reverse bool, limit int64, ...) error
- func (st *Database) ManifestsByFilter(filter interface{}, load, reverse bool, limit int64, ...) error
- func (st *Database) New() (*Database, error)
- func (st *Database) NewOperationSeals(seals []operation.Seal) error
- func (st *Database) NewOperations(ops []operation.Operation) error
- func (st *Database) NewProposal(proposal base.Proposal) error
- func (st *Database) NewSession(blk block.Block) (storage.DatabaseSession, error)
- func (st *Database) NewState(sta state.State) error
- func (st *Database) NewSyncerSession() (storage.SyncerSession, error)
- func (st *Database) Proposal(h valuehash.Hash) (base.Proposal, bool, error)
- func (st *Database) ProposalByPoint(height base.Height, round base.Round, proposer base.Address) (base.Proposal, bool, error)
- func (st *Database) Proposals(callback func(base.Proposal) (bool, error), sort bool) error
- func (st *Database) Readonly() (*Database, error)
- func (st *Database) SaveLastBlock(height base.Height) error
- func (st *Database) SetBlockdataMaps(bds []block.BlockdataMap) error
- func (st *Database) SetInfo(key string, b []byte) error
- func (st *Database) StagedOperations(callback func(operation.Operation) (bool, error), sort bool) error
- func (st *Database) StagedOperationsByFact(facts []valuehash.Hash) ([]operation.Operation, error)
- func (st *Database) State(key string) (state.State, bool, error)
- func (st *Database) UnstagedOperations(facts []valuehash.Hash) error
- func (st *Database) Voteproof(height base.Height, stage base.Stage) (base.Voteproof, error)
- type DatabaseSession
- func (bst *DatabaseSession) Block() block.Block
- func (bst *DatabaseSession) Cancel() error
- func (bst *DatabaseSession) Close() error
- func (bst *DatabaseSession) Commit(ctx context.Context, bd block.BlockdataMap) error
- func (bst *DatabaseSession) SetACCEPTVoteproof(voteproof base.Voteproof) error
- func (bst *DatabaseSession) SetBlock(ctx context.Context, blk block.Block) error
- type Doc
- type HashIDDoc
- type InfoDoc
- type ManifestDoc
- type OperationDoc
- type ProposalDoc
- type StagedOperation
- type StateDoc
- type SyncerSession
- func (st *SyncerSession) Close() error
- func (st *SyncerSession) Commit() error
- func (st *SyncerSession) HasBlock(height base.Height) (bool, error)
- func (st *SyncerSession) Manifest(height base.Height) (block.Manifest, bool, error)
- func (st *SyncerSession) SetBlocks(blocks []block.Block, maps []block.BlockdataMap) error
- func (st *SyncerSession) SetManifests(manifests []block.Manifest) error
- func (st *SyncerSession) SetSkipLastBlock(b bool)
- type VoteproofDoc
Constants ¶
View Source
const ( ColNameInfo = "info" ColNameManifest = "manifest" ColNameOperation = "operation" ColNameStagedOperation = "staged_operation" ColNameProposal = "proposal" ColNameState = "state" ColNameVoteproof = "voteproof" ColNameBlockdataMap = "blockdata_map" )
Variables ¶
View Source
var IndexPrefix = "mitum_"
Functions ¶
func CleanTemporayDatabase ¶
func LoadDataFromDoc ¶
func MergeError ¶
Types ¶
type BaseDocUnpacker ¶
type BlockDoc ¶
type BlockDoc struct { BaseDoc // contains filtered or unexported fields }
func (BlockDoc) MarshalBSON ¶
type BlockdataMapDoc ¶
type BlockdataMapDoc struct { BaseDoc // contains filtered or unexported fields }
func NewBlockdataMapDoc ¶
func NewBlockdataMapDoc(bd block.BlockdataMap, enc encoder.Encoder) (BlockdataMapDoc, error)
func (BlockdataMapDoc) MarshalBSON ¶
func (bd BlockdataMapDoc) MarshalBSON() ([]byte, error)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Collection ¶
func (cl *Client) Collection(col string) *mongo.Collection
func (*Client) Collections ¶
func (*Client) CopyCollection ¶
func (*Client) Delete ¶
func (cl *Client) Delete(col string, filter bson.D, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*Client) DropDatabase ¶
func (*Client) GetByFilter ¶
func (*Client) GetByID ¶
func (cl *Client) GetByID( col string, id interface{}, callback getRecordCallback, opts ...*options.FindOneOptions, ) error
func (*Client) WithSession ¶
func (cl *Client) WithSession( callback func(mongo.SessionContext, func(string) *mongo.Collection) (interface{}, error), ) (interface{}, error)
type Database ¶
func NewDatabase ¶
func NewDatabaseFromURI ¶
func (*Database) BlockdataMap ¶
func (*Database) Clean ¶
Clean will drop the existing collections. To keep safe the another collections by user, drop collections instead of drop database.
func (*Database) CreateIndex ¶
func (*Database) HasOperationFact ¶
func (*Database) HasStagedOperation ¶
func (*Database) Initialize ¶
func (*Database) LocalBlockdataMapsByHeight ¶
func (*Database) ManifestByHeight ¶
func (*Database) ManifestsByFilter ¶
func (*Database) NewOperationSeals ¶
func (*Database) NewOperations ¶
func (*Database) NewSession ¶
func (*Database) NewSyncerSession ¶
func (st *Database) NewSyncerSession() (storage.SyncerSession, error)
func (*Database) ProposalByPoint ¶
func (*Database) SetBlockdataMaps ¶
func (st *Database) SetBlockdataMaps(bds []block.BlockdataMap) error
func (*Database) StagedOperations ¶
func (*Database) StagedOperationsByFact ¶
func (*Database) UnstagedOperations ¶
type DatabaseSession ¶
type DatabaseSession struct {
// contains filtered or unexported fields
}
func NewDatabaseSession ¶
func NewDatabaseSession(st *Database, blk block.Block) (*DatabaseSession, error)
func (*DatabaseSession) Block ¶
func (bst *DatabaseSession) Block() block.Block
func (*DatabaseSession) Cancel ¶
func (bst *DatabaseSession) Cancel() error
func (*DatabaseSession) Close ¶
func (bst *DatabaseSession) Close() error
func (*DatabaseSession) Commit ¶
func (bst *DatabaseSession) Commit(ctx context.Context, bd block.BlockdataMap) error
func (*DatabaseSession) SetACCEPTVoteproof ¶
func (bst *DatabaseSession) SetACCEPTVoteproof(voteproof base.Voteproof) error
type InfoDoc ¶
type InfoDoc struct { BaseDoc // contains filtered or unexported fields }
func (InfoDoc) MarshalBSON ¶
type ManifestDoc ¶
type ManifestDoc struct { BaseDoc // contains filtered or unexported fields }
func NewManifestDoc ¶
func (ManifestDoc) MarshalBSON ¶
func (md ManifestDoc) MarshalBSON() ([]byte, error)
type OperationDoc ¶
type OperationDoc struct { BaseDoc // contains filtered or unexported fields }
func NewOperationDoc ¶
func (OperationDoc) MarshalBSON ¶
func (od OperationDoc) MarshalBSON() ([]byte, error)
type ProposalDoc ¶
type ProposalDoc struct { BaseDoc // contains filtered or unexported fields }
func NewProposalDoc ¶
func (ProposalDoc) MarshalBSON ¶
func (pd ProposalDoc) MarshalBSON() ([]byte, error)
type StagedOperation ¶
type StagedOperation struct { BaseDoc // contains filtered or unexported fields }
func NewStagedOperation ¶
func (StagedOperation) MarshalBSON ¶
func (sd StagedOperation) MarshalBSON() ([]byte, error)
type StateDoc ¶
type StateDoc struct { BaseDoc // contains filtered or unexported fields }
func (StateDoc) MarshalBSON ¶
type SyncerSession ¶
type SyncerSession struct { sync.RWMutex *logging.Logging // contains filtered or unexported fields }
func NewSyncerSession ¶
func NewSyncerSession(main *Database) (*SyncerSession, error)
func (*SyncerSession) Close ¶
func (st *SyncerSession) Close() error
func (*SyncerSession) Commit ¶
func (st *SyncerSession) Commit() error
func (*SyncerSession) HasBlock ¶
func (st *SyncerSession) HasBlock(height base.Height) (bool, error)
func (*SyncerSession) SetBlocks ¶
func (st *SyncerSession) SetBlocks(blocks []block.Block, maps []block.BlockdataMap) error
func (*SyncerSession) SetManifests ¶
func (st *SyncerSession) SetManifests(manifests []block.Manifest) error
func (*SyncerSession) SetSkipLastBlock ¶
func (st *SyncerSession) SetSkipLastBlock(b bool)
type VoteproofDoc ¶
type VoteproofDoc struct { BaseDoc // contains filtered or unexported fields }
func NewVoteproofDoc ¶
func (VoteproofDoc) MarshalBSON ¶
func (pd VoteproofDoc) MarshalBSON() ([]byte, error)
Click to show internal directories.
Click to hide internal directories.