models

package
v0.0.0-...-7bb7a1f Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	READ   = "read"
	UNREAD = "unread"
)

Variables

This section is empty.

Functions

func FindAll

func FindAll(collection string, results types.Document, filter bson.D, opts *options.FindOptions) error

func FindAllUsers

func FindAllUsers(filter bson.D) (*[]User, error)

func FindMessages

func FindMessages(filter bson.D, opts *options.FindOptions) (*[]Message, error)

func FindOne

func FindOne(collection string, filter bson.M, result Model) error

func Insert

func Insert(collection string, model Model) error

func InsertMessages

func InsertMessages(message *Message) error

func InsertUser

func InsertUser(user *User) error

func Update

func Update(collection string, filter bson.M, update primitive.D) error

func UpdateMessages

func UpdateMessages(message *Message, feilds primitive.E) error

func UpdateUser

func UpdateUser(user *User, filter bson.M, update bson.D) error

Types

type BaseModel

type BaseModel struct {
	ID        string             `json:"id" bson:"_id,omitempty"`
	CreatedAt primitive.DateTime `json:"created_at" bson:"created_at"`
	UpdatedAt primitive.DateTime `json:"updated_at" bson:"updated_at"`
}

func (*BaseModel) GetCreatedAt

func (b *BaseModel) GetCreatedAt() primitive.DateTime

func (*BaseModel) GetId

func (b *BaseModel) GetId() string

func (*BaseModel) GetUpdatedAt

func (b *BaseModel) GetUpdatedAt() primitive.DateTime

func (*BaseModel) SetCreatedAt

func (b *BaseModel) SetCreatedAt()

func (*BaseModel) SetUpdatedAt

func (b *BaseModel) SetUpdatedAt()

type Message

type Message struct {
	BaseModel  `bson:",inline"`
	ReceiverId string `json:"receiver_id" bson:"receiver_id,omitempty"`
	Status     string `json:"status" bson:"status,omitempty"`
	UserId     string `json:"user_id" bson:"user_id,omitempty"`
	Text       string `json:"text" bson:"text,omitempty"`
	Type       string `json:"type"`
}

func FindMessage

func FindMessage(value string) (*Message, error)

func NewMessage

func NewMessage(user_id string, receiver_id string, message string) *Message

func (*Message) CollectionName

func (user *Message) CollectionName() string

type Model

type Model interface {
	CollectionName() string
	GetId() string
	GetCreatedAt() primitive.DateTime
	GetUpdatedAt() primitive.DateTime
	SetCreatedAt()
	SetUpdatedAt()
}

type User

type User struct {
	BaseModel `bson:",inline"`
	ID        string   `json:"id" bson:"_id,omitempty"`
	Name      string   `json:"name" bson:"name,omitempty"`
	Email     string   `json:"email" bson:"email,omitempty"`
	Picture   string   `json:"picture" bson:"picture,omitempty"`
	Contacts  []string `json:"contacts" bson:"contacts,omitempty"`
	//Role     string `json:"role" bson:"role,omitempty"`
	Password []byte `json:"-"`
}

func FindUser

func FindUser(key string, value string) (*User, error)

func FindUserById

func FindUserById(value string) (*User, error)

func NewUser

func NewUser(name string, email string, password []byte) *User

func (*User) CollectionName

func (user *User) CollectionName() string

Jump to

Keyboard shortcuts

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