Documentation
¶
Overview ¶
Package model provides chat-related data models and database operations. It includes message handling functionality with CRUD operations using LevelDB and Protocol Buffers.
Package model provides data models and database operations for the DM-Backend application. It includes user management functionality with CRUD operations using LevelDB and Protocol Buffers.
Index ¶
- Variables
- func UserExists(userName string) (bool, error)
- type User
- func (d *User) DeleteUserData(userName string) error
- func (*User) Descriptor() ([]byte, []int)deprecated
- func (x *User) GetAccountTime() int64
- func (x *User) GetBirthDate() int64
- func (x *User) GetEmail() string
- func (x *User) GetGender() string
- func (x *User) GetLastEdit() int64
- func (x *User) GetPassword() string
- func (x *User) GetPersonId() string
- func (x *User) GetPhoneNumber() string
- func (x *User) GetProfile() string
- func (x *User) GetProfilePicUrl() string
- func (g *User) GetUserData(userName string) error
- func (x *User) GetUserName() string
- func (*User) ProtoMessage()
- func (x *User) ProtoReflect() protoreflect.Message
- func (x *User) Reset()
- func (s *User) SaveUserData() error
- func (x *User) String() string
- func (u *User) UpdateUserData(userName string) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrMessageNotFound = errors.New("message not found") ErrChatHistoryNotFound = errors.New("chat history not found") ErrInvalidMessageID = errors.New("message ID cannot be empty") ErrInvalidConvID = errors.New("conversation ID cannot be empty") )
Common errors for chat operations
var ( ErrUserNotFound = errors.New("user not found") ErrDatabaseOpen = errors.New("failed to open database") ErrSerialize = errors.New("failed to serialize user data") ErrDeserialize = errors.New("failed to deserialize user data") ErrDatabaseWrite = errors.New("failed to write to database") ErrDatabaseRead = errors.New("failed to read from database") ErrDatabaseDelete = errors.New("failed to delete from database") ErrInvalidUsername = errors.New("username cannot be empty") )
Common errors for user operations
var File_user_proto protoreflect.FileDescriptor
Functions ¶
func UserExists ¶
UserExists checks if a user exists in the database. Returns true if the user exists, false otherwise.
Types ¶
type User ¶
type User struct {
UserName string `protobuf:"bytes,1,opt,name=user_name,json=userName,proto3" json:"user_name,omitempty"`
PersonId string `protobuf:"bytes,2,opt,name=person_id,json=personId,proto3" json:"person_id,omitempty"`
Profile string `protobuf:"bytes,3,opt,name=profile,proto3" json:"profile,omitempty"`
Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"`
Email string `protobuf:"bytes,5,opt,name=email,proto3" json:"email,omitempty"`
ProfilePicUrl string `protobuf:"bytes,6,opt,name=profile_pic_url,json=profilePicUrl,proto3" json:"profile_pic_url,omitempty"`
AccountTime int64 `protobuf:"varint,7,opt,name=account_time,json=accountTime,proto3" json:"account_time,omitempty"`
BirthDate int64 `protobuf:"varint,8,opt,name=birth_date,json=birthDate,proto3" json:"birth_date,omitempty"`
Gender string `protobuf:"bytes,9,opt,name=gender,proto3" json:"gender,omitempty"`
LastEdit int64 `protobuf:"varint,10,opt,name=last_edit,json=lastEdit,proto3" json:"last_edit,omitempty"`
PhoneNumber string `protobuf:"bytes,11,opt,name=phone_number,json=phoneNumber,proto3" json:"phone_number,omitempty"`
// contains filtered or unexported fields
}
func (*User) DeleteUserData ¶
DeleteUserData removes the user data from the database. Returns an error if the user is not found or if the delete operation fails.
func (*User) Descriptor
deprecated
func (*User) GetAccountTime ¶
func (*User) GetBirthDate ¶
func (*User) GetLastEdit ¶
func (*User) GetPassword ¶
func (*User) GetPersonId ¶
func (*User) GetPhoneNumber ¶
func (*User) GetProfile ¶
func (*User) GetProfilePicUrl ¶
func (*User) GetUserData ¶
GetUserData retrieves user data from the database using the provided username. The retrieved data is unmarshaled into the User struct receiver. Returns an error if the user is not found or if database operations fail.
func (*User) GetUserName ¶
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()
func (*User) ProtoReflect ¶
func (x *User) ProtoReflect() protoreflect.Message
func (*User) SaveUserData ¶
SaveUserData persists the user data to the LevelDB database. It uses the PersonId as the key for storage. Returns an error if the database operation fails.
func (*User) UpdateUserData ¶
UpdateUserData updates the user data in the database. It retrieves the existing user by username, updates with new data from the receiver, and writes the updated data back to the database. Returns an error if the user is not found or if database operations fail.