database

package
v0.0.0-...-4185ac2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSession

func GetSession(col *Collection, key string) (*objects.Session, error)

GetSession finds and returns session. Error if session isn't found

func GetUserByID

func GetUserByID(col *Collection, id primitive.ObjectID) (*objects.User, error)

GetUserByID finds user in database by id and returns pointer to user object

func GetUserByUsernameOrEmail

func GetUserByUsernameOrEmail(col *Collection, u string) (*objects.User, primitive.ObjectID, error)

GetUserByUsernameOrEmail will retrieve user for username or email

func MongoFilterID

func MongoFilterID(id string) (bson.D, error)

MongoFilterID takes id string and returns proper BSON object

func UpdateSessionLastSeen

func UpdateSessionLastSeen(col *Collection, session *objects.Session)

UpdateSessionLastSeen updates the TimeStamp of LastSeenTime in the session document

Types

type Collection

type Collection struct {
	*mongo.Collection
}

Collection (table) to access documents (rows)

type Database

type Database struct {
	*mongo.Database
}

Database struct contains whatever db client we are using

func ConnectDB

func ConnectDB() *Database

ConnectDB connects to a specified database, and puts it in type Database

func (*Database) GetMongoCollection

func (db *Database) GetMongoCollection(collection string) *Collection

GetMongoCollection returns a collection of the Database db

Jump to

Keyboard shortcuts

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