store

package
v0.0.0-...-1eed7ee Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupMongoSession

func CleanupMongoSession()

CleanupMongoSession closes the current session and sets the pointer to nil

func InitMongoSession

func InitMongoSession() error

InitMongoSession resets the mongo session pointer with updated connection info

func Nuke

func Nuke() error

Nuke destroys the database if it is in a test environment

Types

type MongoStore

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

func NewMongoStore

func NewMongoStore() (*MongoStore, error)

NewMongoStore returns an instance of the store with a copied mongo session error is 500 if mongo ping fails

func (*MongoStore) AdminExistsOrCreate

func (m *MongoStore) AdminExistsOrCreate(secret string) error

AdminExistsOrCreate checks for existence of admin account and creates one with given key if it doesn't exist

func (*MongoStore) Cleanup

func (m *MongoStore) Cleanup()

Cleanup closes the mongo session of this store object

func (*MongoStore) CreateUser

func (m *MongoStore) CreateUser(user *schema.User) error

CreateUser inserts user object into db error is 500 if mongo fails, 409 if user exists, else nil

func (*MongoStore) DeleteUser

func (m *MongoStore) DeleteUser(userID string) (*schema.UserSecure, error)

DeleteUser removes user from db with given username error is 500 if mongo fails, else nil

func (*MongoStore) GetAllUsers

func (m *MongoStore) GetAllUsers() ([]*schema.UserSecure, error)

GetAllUsers retrieves all users

func (*MongoStore) GetDatabase

func (m *MongoStore) GetDatabase() *mgo.Database

GetDatabase returns a pointer to an mgo database object

func (*MongoStore) GetUser

func (m *MongoStore) GetUser(q bson.M) (*schema.UserSecure, error)

GetUser looks up user in db with given query for entire object (excpet password) error is 500 if mongo fails, else nil

func (*MongoStore) GetUserByCreds

func (m *MongoStore) GetUserByCreds(user, pw string) (*schema.UserSecure, error)

GetUserByCreds looks up user with given username, password

func (*MongoStore) GetUserByEmail

func (m *MongoStore) GetUserByEmail(email string) (*schema.UserSecure, error)

GetUserByEmail looks up user with given email

func (*MongoStore) GetUserByID

func (m *MongoStore) GetUserByID(id string) (*schema.UserSecure, error)

GetUserByID looks up user with given object id

func (*MongoStore) GetUserByUsername

func (m *MongoStore) GetUserByUsername(username string) (*schema.UserSecure, error)

GetUserByUsername looks up user with given username

func (*MongoStore) GetUsersCollection

func (m *MongoStore) GetUsersCollection() *mgo.Collection

GetUsersCollection returns an mgo instance to the users collection

func (*MongoStore) UpdateUser

func (m *MongoStore) UpdateUser(userID string, user *schema.User) (*schema.UserSecure, error)

UpdateUser ... TODO check for username exists and email exists

Jump to

Keyboard shortcuts

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