database

package
v0.0.0-...-7f33b96 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2021 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMatcherProjectPipeline

func CreateMatcherProjectPipeline(matcher bson.M, project bson.M) []primitive.M

CreateMatcherProjectPipeline creates a pipeline with a match and project

func CreatePermissionFilter

func CreatePermissionFilter(groups []primitive.ObjectID, user string) bson.M

CreatePermissionFilter creates a filter bson that matches the owner and it's groups

func CreatePermissionMatcher

func CreatePermissionMatcher(permission bson.M, id primitive.ObjectID) (bson.M, error)

CreatePermissionMatcher creates a matcher that checks for permissions

func CreatePermissionProjectPipeline

func CreatePermissionProjectPipeline(permission bson.M, id primitive.ObjectID, project bson.M) ([]primitive.M, error)

CreatePermissionProjectPipeline creates a pipeline with permission for a specific user and model project

func ManageField

func ManageField(db *mongo.Database, collection string, filter *bson.M, value *bson.M) int

ManageField executs a specific bson on a filter e.x.: filter := bson.M{"_id": bson.M{"$eq": objID}} value := bson.M{"$set": bson.M{"fieldint": 42}}

0 -> ok | 1 -> error when updating | 2 -> nothing modified in DB

Types

type DBConnection

type DBConnection struct {
	Col    *mongo.Collection
	Ctx    context.Context
	Cancel context.CancelFunc
}

DBConnection holds information about the collection and the context

func GetColCtx

func GetColCtx(model string, db *mongo.Database, duration time.Duration) DBConnection

GetColCtx returns the collection for the specified model and initializes a timeout context with passed duration

Jump to

Keyboard shortcuts

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