mongodb

package
v0.0.0-...-cc9b1f3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Ver is the field name that notes the version.
	Ver = "_orda_ver_"
)

Variables

This section is empty.

Functions

func MakeCollection

func MakeCollection(ctx iface.OrdaContext, mongo *RepositoryMongo, collectionName string) (int32, errors.OrdaError)

MakeCollection makes a real collection.

Types

type Config

type Config struct {
	Host     string `json:"MongoHost"`
	OrdaDB   string `json:"OrdaDB"`
	User     string `json:"User"`
	Password string `json:"Password"`
	CertFile string `json:"CertFile"`
	Options  string `json:"Options"`
}

Config is a configuration for MongoDB

func (*Config) MarshalJSON

func (its *Config) MarshalJSON() ([]byte, error)

MarshalJSON returns marshaled JSON

func (*Config) String

func (its *Config) String() string

type MongoCollections

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

MongoCollections is a bunch of collections used to provide

func (*MongoCollections) DeleteClient

func (its *MongoCollections) DeleteClient(ctx iface.OrdaContext, cuid string) errors.OrdaError

DeleteClient deletes the specified client.

func (*MongoCollections) DeleteCollection

func (its *MongoCollections) DeleteCollection(ctx iface.OrdaContext, name string) errors.OrdaError

DeleteCollection deletes collections with the specified name.

func (*MongoCollections) DeleteOperation

func (its *MongoCollections) DeleteOperation(
	ctx iface.OrdaContext,
	duid string,
	sseq uint32,
) (int64, errors.OrdaError)

DeleteOperation deletes operations for the specified sseq

func (*MongoCollections) GetClient

func (its *MongoCollections) GetClient(
	ctx iface.OrdaContext,
	cuid string,
) (*schema.ClientDoc, errors.OrdaError)

GetClient returns a ClientDoc for the specified CUID.

func (*MongoCollections) GetCollection

func (its *MongoCollections) GetCollection(ctx iface.OrdaContext, name string) (*schema.CollectionDoc, errors.OrdaError)

GetCollection gets a collectionDoc with the specified name.

func (*MongoCollections) GetDatatype

func (its *MongoCollections) GetDatatype(
	ctx iface.OrdaContext,
	duid string,
) (*schema.DatatypeDoc, errors.OrdaError)

GetDatatype retrieves a datatypeDoc from MongoDB

func (*MongoCollections) GetDatatypeByKey

func (its *MongoCollections) GetDatatypeByKey(
	ctx iface.OrdaContext,
	collectionNum int32,
	key string,
) (*schema.DatatypeDoc, errors.OrdaError)

GetDatatypeByKey gets a datatype with the specified key.

func (*MongoCollections) GetLatestSnapshot

func (its *MongoCollections) GetLatestSnapshot(
	ctx iface.OrdaContext,
	collectionNum int32,
	duid string,
) (*schema.SnapshotDoc, errors.OrdaError)

GetLatestSnapshot gets the latest snapshot for the specified datatype.

func (*MongoCollections) GetNextCollectionNum

func (its *MongoCollections) GetNextCollectionNum(ctx iface.OrdaContext) (int32, errors.OrdaError)

GetNextCollectionNum gets a collection number that is assigned to a collection.

func (*MongoCollections) GetOperations

func (its *MongoCollections) GetOperations(
	ctx iface.OrdaContext,
	duid string,
	from, to uint64,
) (model.OpList, []uint64, errors.OrdaError)

GetOperations gets operations of the specified range. For each operation, a given handler is called.

func (*MongoCollections) InsertCollection

func (its *MongoCollections) InsertCollection(
	ctx iface.OrdaContext,
	name string,
) (collection *schema.CollectionDoc, err errors.OrdaError)

InsertCollection inserts a document for the specified collection.

func (*MongoCollections) InsertOperations

func (its *MongoCollections) InsertOperations(
	ctx iface.OrdaContext,
	operations []interface{},
) errors.OrdaError

InsertOperations inserts operations into MongoDB

func (*MongoCollections) InsertSnapshot

func (its *MongoCollections) InsertSnapshot(
	ctx iface.OrdaContext,
	collectionNum int32,
	duid string,
	sseq uint64,
	meta []byte,
	snapshot []byte,
) errors.OrdaError

InsertSnapshot inserts a snapshot for the specified datatype.

func (*MongoCollections) PurgeAllDocumentsOfCollection

func (its *MongoCollections) PurgeAllDocumentsOfCollection(ctx iface.OrdaContext, name string) errors.OrdaError

PurgeAllDocumentsOfCollection purges all data for the specified collection.

func (*MongoCollections) PurgeDatatype

func (its *MongoCollections) PurgeDatatype(
	ctx iface.OrdaContext,
	collectionNum int32,
	key string,
) errors.OrdaError

PurgeDatatype purges a datatype from MongoDB.

func (*MongoCollections) PurgeOperations

func (its *MongoCollections) PurgeOperations(ctx iface.OrdaContext, collectionNum int32, duid string) errors.OrdaError

PurgeOperations purges operations for the specified datatype.

func (*MongoCollections) UpdateClient

func (its *MongoCollections) UpdateClient(
	ctx iface.OrdaContext,
	client *schema.ClientDoc,
) errors.OrdaError

UpdateClient updates a clientDoc; if not exists, a new clientDoc is inserted.

func (*MongoCollections) UpdateDatatype

func (its *MongoCollections) UpdateDatatype(
	ctx iface.OrdaContext,
	datatype *schema.DatatypeDoc,
) errors.OrdaError

UpdateDatatype updates the datatypeDoc.

type RepositoryMongo

type RepositoryMongo struct {
	*MongoCollections
	// contains filtered or unexported fields
}

RepositoryMongo is a tool struct for MongoDB

func New

New creates a new RepositoryMongo

func (*RepositoryMongo) Close

Close closes the repository of MongoDB

func (*RepositoryMongo) GetOrCreateRealCollection

func (its *RepositoryMongo) GetOrCreateRealCollection(ctx iface.OrdaContext, name string) errors.OrdaError

GetOrCreateRealCollection is a method that gets or creates a collection of snapshot

func (*RepositoryMongo) GetRealSnapshot

func (its *RepositoryMongo) GetRealSnapshot(
	ctx iface.OrdaContext,
	collectionName string,
	id string,
) (map[string]interface{}, errors.OrdaError)

GetRealSnapshot returns a real snapshot

func (*RepositoryMongo) InitializeCollections

func (its *RepositoryMongo) InitializeCollections(ctx iface.OrdaContext) errors.OrdaError

InitializeCollections initializes collections

func (*RepositoryMongo) InsertRealSnapshot

func (its *RepositoryMongo) InsertRealSnapshot(
	ctx iface.OrdaContext,
	collectionName string,
	id string,
	data interface{},
	sseq uint64,
) errors.OrdaError

InsertRealSnapshot inserts a snapshot for real collection.

func (*RepositoryMongo) PurgeCollection

func (its *RepositoryMongo) PurgeCollection(ctx iface.OrdaContext, collectionName string) errors.OrdaError

PurgeCollection purges all collections related to collectionName

Jump to

Keyboard shortcuts

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