models

package
v0.0.0-...-363efc0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(tweet Tweet) (string, bool, error)

Create stores a record

func CreateRelation

func CreateRelation(relation Relation) (bool, error)

CreateRelation for users

func CreateUser

func CreateUser(user User) (string, bool, error)

CreateUser store a user

func Delete

func Delete(ID string, UserID string) error

Delete delete a register tweet

func DeleteRelation

func DeleteRelation(relation Relation) (bool, error)

DeleteRelation for users

func ReadRelation

func ReadRelation(relation Relation) (bool, error)

ReadRelation for users

func ReadTweetFollowers

func ReadTweetFollowers(ID string, page int64) ([]structs.ResponseTweetsFollowers, bool)

ReadTweetFollowers read all tweet of followers specific user

func UpdateUser

func UpdateUser(user User, ID string) (bool, error)

UpdateUser updated information user

Types

type Claim

type Claim struct {
	Email string             `json:"email"`
	ID    primitive.ObjectID `bson:"_id" json:"_id,omitempty"`
	jwt.StandardClaims
}

Claim decode info token

type Relation

type Relation struct {
	UserID       string `bson:"userid" json:"userid"`
	UserRelation string `bson:"userrelation" json:"userrelation"`
}

Relation of users

type Tweet

type Tweet struct {
	ID       primitive.ObjectID `bson:"_id" json:"id,omitempty"`
	UserID   string             `bson:"userid" json:"userid,omitempty"`
	Message  string             `bson:"message" json:"message,omitempty"`
	CreateAt time.Time          `bson:"createAt" json:"createAt,omitempty"`
}

Tweet model tweets

func Read

func Read(userID string, page int64) ([]*Tweet, bool)

Read roturn all tweets

type User

type User struct {
	ID        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	Name      string             `bson:"name,omitempty" json:"name,omitempty"`
	LastName  string             `bson:"lastName,omitempty" json:"lastName,omitempty"`
	BirthDate time.Time          `bson:"birthDate,omitempty" json:"birthDate,omitempty"`
	Email     string             `bson:"email" json:"email,omitempty"`
	Password  string             `bson:"password" json:"password,omitempty"`
	Avatar    string             `bson:"avatar,omitempty" json:"avatar,omitempty"`
	Banner    string             `bson:"banner,omitempty" json:"banner,omitempty"`
	Biography string             `bson:"biography,omitempty" json:"biography,omitempty"`
	Location  string             `bson:"location,omitempty" json:"location,omitempty"`
	WebSite   string             `bson:"webSite,omitempty" json:"webSite,omitempty"`
}

User data structure

func CheckSignIn

func CheckSignIn(email string, password string) (User, bool)

CheckSignIn for auth user

func ExistsUser

func ExistsUser(email string) (User, bool, string)

ExistsUser verify if a user exists

func GetUser

func GetUser(ID string) (User, error)

GetUser get information of one user

func ReadAllUsers

func ReadAllUsers(ID string, page int64, search string, typeUser string) ([]*User, bool)

ReadAllUsers get all user by contifion for parameters

Jump to

Keyboard shortcuts

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