mongo

package
v0.0.0-...-a9a9e39 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USERS = "users"
)

Variables

View Source
var (
	ErrConnectionRefused = errors.New("Cannot connect to database")
)
View Source
var (
	ErrCourseExists = errors.New("datastore.mongo.user.save.user_exists")
)
View Source
var (
	ErrUserExists = errors.New("datastore.mongo.user.save.user_exists")
)

Functions

func IDStringFromResult

func IDStringFromResult(oid interface{}) string

func IDToObjectID

func IDToObjectID(id string) (primitive.ObjectID, error)

func IDsToObjectIDs

func IDsToObjectIDs(ids []string) ([]primitive.ObjectID, error)

func NewMongoDatastore

func NewMongoDatastore() (datastore.Datastore, error)

func ToObjectID

func ToObjectID(id string) (primitive.ObjectID, error)

Types

type CourseStore

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

func (*CourseStore) Count

func (s *CourseStore) Count(c context.Context) (int64, error)

func (*CourseStore) Get

func (s *CourseStore) Get(c context.Context, id string) (*models.Course, error)

func (*CourseStore) GetAll

func (s *CourseStore) GetAll(c context.Context) ([]*models.Course, error)

func (*CourseStore) Save

func (s *CourseStore) Save(c context.Context, course *models.Course) error

type FileInfoStore

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

func (*FileInfoStore) Count

func (s *FileInfoStore) Count(c context.Context) (int64, error)

func (*FileInfoStore) Get

func (*FileInfoStore) GetAll

func (s *FileInfoStore) GetAll(c context.Context) ([]*models.FileInfo, error)

func (*FileInfoStore) Save

type Model

type Model interface {
	GetID() string
	SetID(string)
}

type MongoDatastore

type MongoDatastore struct {
	DB     *mongo.Database
	Client *mongo.Client
	// contains filtered or unexported fields
}

func (*MongoDatastore) Coll

func (s *MongoDatastore) Coll(name string) *mongo.Collection

func (*MongoDatastore) Count

func (s *MongoDatastore) Count(c context.Context, collection string) (int64, error)

func (*MongoDatastore) Course

func (s *MongoDatastore) Course() datastore.CourseStore

func (*MongoDatastore) FileInfo

func (s *MongoDatastore) FileInfo() datastore.FileInfoStore

func (*MongoDatastore) Find

func (s *MongoDatastore) Find(c context.Context, collection string, decode interface{}) error

func (*MongoDatastore) FindByID

func (s *MongoDatastore) FindByID(c context.Context, collection string, id string, decode interface{}) error

func (*MongoDatastore) FindByIDs

func (s *MongoDatastore) FindByIDs(c context.Context, collection string, ids []string, decode interface{}) error

func (*MongoDatastore) Insert

func (s *MongoDatastore) Insert(c context.Context, collection string, model interface{}) (string, error)

func (*MongoDatastore) TestConnection

func (s *MongoDatastore) TestConnection(c context.Context) error

func (*MongoDatastore) Update

func (s *MongoDatastore) Update(c context.Context, collection string, model Model) error

func (*MongoDatastore) User

type UserStore

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

func (*UserStore) Count

func (s *UserStore) Count(c context.Context) (int64, error)

func (*UserStore) Get

func (s *UserStore) Get(c context.Context, id string) (*models.User, error)

func (*UserStore) GetAll

func (s *UserStore) GetAll(c context.Context, opts *models.UserGetOptions) ([]*models.User, error)

func (*UserStore) GetByIDs

func (s *UserStore) GetByIDs(c context.Context, userIDs []string) ([]*models.User, error)

func (*UserStore) GetByUsername

func (s *UserStore) GetByUsername(c context.Context, username string) (*models.User, error)

func (*UserStore) Save

func (s *UserStore) Save(c context.Context, user *models.User) error

func (*UserStore) Update

func (s *UserStore) Update(c context.Context, user *models.User) error

Jump to

Keyboard shortcuts

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