models

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type LoginResponse

type LoginResponse struct {
	ID    string `json:"user_id"`
	Token string `json:"token"`
}

type Photo

type Photo struct {
	ID          string `json:"id"`
	Base64      string `json:"base64"`
	OwnerID     string `json:"owner_id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        string `json:"type"`
}

func (Photo) ToDAO

func (p Photo) ToDAO(dao *PhotoDAO)

ToDAO Transfers the data from a Photo struct to a PhotoDAO struct.

type PhotoDAO

type PhotoDAO struct {
	ID          primitive.ObjectID `bson:"_id,omitempty"`
	Base64      string             `bson:"base64"`
	OwnerID     primitive.ObjectID `bson:"owner_id"`
	Name        string             `bson:"name"`
	Description string             `bson:"description"`
	Type        string             `bson:"type"`
}

PhotoDAO is a version of Photo that is used by MongoDB to interact with the data

func (PhotoDAO) ToModel

func (dao PhotoDAO) ToModel(p *Photo)

ToModel Transfers the data from a PhotoDAO struct to a Photo struct.

type SignUpRequest

type SignUpRequest struct {
	Name              string `json:"name"`
	Email             string `json:"email"`
	Password          string `json:"password"`
	SubscriptionPrice int64  `json:"subscription_price"`
}

type SignUpResponse

type SignUpResponse struct {
	ID    string `json:"user_id"`
	Token string `json:"token"`
}

type User

type User struct {
	ID                string   `json:"id"`
	Name              string   `json:"name"`
	Email             string   `json:"email"`
	Subscriptions     []string `json:"subscriptions"`
	Photos            []string `json:"photos"`
	Balance           int64    `json:"balance"`
	SubscriptionPrice int64    `json:"subscription_price"`
}

func (User) IsSubscribedTo

func (u User) IsSubscribedTo(id string) bool

IsSubscribedTo checks is a user is subscribed to another user by its ID

func (*User) ToDAO

func (u *User) ToDAO(user *UserDAO)

ToDAO transfers the data from a User struct to a UserDAO struct

type UserAuth

type UserAuth struct {
	ID           string `json:"id,omitempty"`
	Email        string `json:"email"`
	UserID       string `json:"user_id"`
	PasswordHash string `json:"password_hash"`
}

func (*UserAuth) ToDAO

func (u *UserAuth) ToDAO(dao *UserAuthDAO)

ToDAO Transfers the data from a UserAuth struct to a UserAuthDAO struct.

type UserAuthDAO

type UserAuthDAO struct {
	ID           primitive.ObjectID `bson:"_id,omitempty"`
	Email        string             `bson:"email"`
	UserID       primitive.ObjectID `bson:"user_id"`
	PasswordHash string             `bson:"password_hash"`
}

UserAuthDAO is a version of UserAuth that is used by MongoDB to interact with the data

func (*UserAuthDAO) ToModel

func (dao *UserAuthDAO) ToModel(auth *UserAuth)

ToModel Transfers the data from a UserAuthDAO struct to a UserAuth struct.

type UserDAO

type UserDAO struct {
	ID                string               `bson:"_id,omitempty"`
	Name              string               `bson:"name"`
	Email             string               `bson:"email"`
	Subscriptions     []primitive.ObjectID `json:"subscriptions"`
	Photos            []primitive.ObjectID `bson:"photos"`
	Balance           int64                `bson:"balance"`
	SubscriptionPrice int64                `bson:"subscription_price"`
}

UserDAO is a version of User that is used by MongoDB to interact with the data

func (*UserDAO) ToModel

func (u *UserDAO) ToModel(user *User)

ToModel transfers the data from a UserDAO struct to a User struct

Jump to

Keyboard shortcuts

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