Documentation ¶
Index ¶
- type MongoConnection
- func (m *MongoConnection) AddAsset(ctx context.Context, OID string, asset custodian.Asset) error
- func (m *MongoConnection) CloseClientDB(ctx context.Context)
- func (m *MongoConnection) DeleteAsset(ctx context.Context, OID string) error
- func (m *MongoConnection) EraseCollection(ctx context.Context) error
- func (m *MongoConnection) Exists(ctx context.Context, OID string) (bool, error)
- func (m *MongoConnection) GetAsset(ctx context.Context, OID string, asset interface{}) error
- func (m *MongoConnection) GetAssetByField(ctx context.Context, field string, value string, asset interface{}) error
- func (m *MongoConnection) GetAssetByFields(ctx context.Context, attributesMap map[string]interface{}, asset interface{}, ...) error
- func (m *MongoConnection) GetAssetByFilter(ctx context.Context, filter bson.M, asset interface{}, ...) error
- func (m *MongoConnection) GetAssetsByField(ctx context.Context, field string, value string) (*mongo.Cursor, error)
- func (m *MongoConnection) GetAssetsByFields(ctx context.Context, attributesMap map[string]interface{}, ...) (*mongo.Cursor, error)
- func (m *MongoConnection) GetAssetsByFieldsSorted(ctx context.Context, attributesMap map[string]interface{}, field string, ...) (*mongo.Cursor, error)
- func (m *MongoConnection) GetAssetsByFilterSorted(ctx context.Context, filter bson.M, field string, order int) (*mongo.Cursor, error)
- func (m *MongoConnection) UpdateAsset(ctx context.Context, OID string, data interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MongoConnection ¶
type MongoConnection struct { MongoURL string Database string Collection string // contains filtered or unexported fields }
func NewMongoDB ¶
func NewMongoDB(mongoURL, database, collection string) MongoConnection
NewMongoDB creates a new MongoConnection object
func (*MongoConnection) AddAsset ¶
func (m *MongoConnection) AddAsset(ctx context.Context, OID string, asset custodian.Asset) error
AddAsset adds a new asset to the database
func (*MongoConnection) CloseClientDB ¶
func (m *MongoConnection) CloseClientDB(ctx context.Context)
CloseClientDB closes the connection to the mongo DB
func (*MongoConnection) DeleteAsset ¶
func (m *MongoConnection) DeleteAsset(ctx context.Context, OID string) error
UpdateAsset updates the asset with corresponding OID using data
func (*MongoConnection) EraseCollection ¶
func (m *MongoConnection) EraseCollection(ctx context.Context) error
EraseCollection erases every documents in a collection
func (*MongoConnection) Exists ¶
Exists checks if a asset with corresponding OID exists in the database
func (*MongoConnection) GetAsset ¶
func (m *MongoConnection) GetAsset(ctx context.Context, OID string, asset interface{}) error
GetAsset gets the asset with corresponding OID from the database, if it exists, and stores it in asset
func (*MongoConnection) GetAssetByField ¶
func (m *MongoConnection) GetAssetByField(ctx context.Context, field string, value string, asset interface{}) error
GetAssetByField gets the asset with corresponding field value from the database, if it exists, and stores it in asset
func (*MongoConnection) GetAssetByFields ¶
func (m *MongoConnection) GetAssetByFields(ctx context.Context, attributesMap map[string]interface{}, asset interface{}, findOptions *options.FindOneOptions) error
GetAssetByFields gets the asset with corresponding field values from the database, if it exists, and stores it in asset
func (*MongoConnection) GetAssetByFilter ¶
func (m *MongoConnection) GetAssetByFilter(ctx context.Context, filter bson.M, asset interface{}, findOptions *options.FindOneOptions) error
GetAssetByFilter gets the asset with corresponding filter from the database, if it exists, and stores it in asset
func (*MongoConnection) GetAssetsByField ¶
func (m *MongoConnection) GetAssetsByField(ctx context.Context, field string, value string) (*mongo.Cursor, error)
GetAssetByField returns all assets with corresponding field value from the database, if it exists
func (*MongoConnection) GetAssetsByFields ¶
func (m *MongoConnection) GetAssetsByFields(ctx context.Context, attributesMap map[string]interface{}, findOptions *options.FindOptions) (*mongo.Cursor, error)
Returns multiple assets corresponding to the fields
func (*MongoConnection) GetAssetsByFieldsSorted ¶
func (m *MongoConnection) GetAssetsByFieldsSorted(ctx context.Context, attributesMap map[string]interface{}, field string, order int) (*mongo.Cursor, error)
GetAssetsByFields gets all assets with corresponding field values from the database, if they exist, and sorts them by field
func (*MongoConnection) GetAssetsByFilterSorted ¶
func (m *MongoConnection) GetAssetsByFilterSorted(ctx context.Context, filter bson.M, field string, order int) (*mongo.Cursor, error)
GetAssetsByFilterSorted gets all assets with corresponding filter from the database, if they exist, and sorts them by field
func (*MongoConnection) UpdateAsset ¶
func (m *MongoConnection) UpdateAsset(ctx context.Context, OID string, data interface{}) error
UpdateAsset updates the asset with corresponding OID using data