database

package
v0.0.0-...-b38d333 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthDB                  = "authDB"
	CollectionRefreshTokens = "refreshToken"
	UserDB                  = "userDB"
	CollectionUsers         = "users"
)

Variables

This section is empty.

Functions

func ConnectAuthDB

func ConnectAuthDB(ctx context.Context, dbURI string) (*mongo.Client, error)

func ConnectUserDB

func ConnectUserDB(ctx context.Context, dbURI string) (*mongo.Client, error)

Types

type AuthDatabase

type AuthDatabase struct {
	*mongo.Database
}

func (AuthDatabase) DeleteRefreshTokenByID

func (db AuthDatabase) DeleteRefreshTokenByID(ctx context.Context, id string) error

func (AuthDatabase) FindRefreshTokenByID

func (db AuthDatabase) FindRefreshTokenByID(ctx context.Context, id string) (RefreshToken, error)

func (AuthDatabase) InsertRefreshToken

func (db AuthDatabase) InsertRefreshToken(ctx context.Context, rt RefreshToken) (string, error)

type RefreshToken

type RefreshToken struct {
	ID         primitive.ObjectID `bson:"_id,omitempty"`
	UserID     primitive.ObjectID `bson:"user_id"`
	Token      []byte             `bson:"token"`
	Expiration primitive.DateTime `bson:"expiration"`
}

type User

type User struct {
	ID       primitive.ObjectID `bson:"_id,omitempty"`
	Username string             `bson:"username"`
	Password []byte             `bson:"password"`
	Role     string             `bson:"role"`
}

type UserDatabase

type UserDatabase struct {
	*mongo.Database
}

func (UserDatabase) FindUserByID

func (db UserDatabase) FindUserByID(ctx context.Context, id string) (User, error)

func (UserDatabase) FindUserByUsername

func (db UserDatabase) FindUserByUsername(ctx context.Context, username string) (User, error)

Jump to

Keyboard shortcuts

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