postgres

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("record not found")
)

Functions

func NewLocationStore

func NewLocationStore(pool *pgxpool.Pool) store.LocationStore

Types

type ChatStore

type ChatStore struct {
	// contains filtered or unexported fields
}

ChatStore implements the store.ChatStore interface using PostgreSQL

func NewChatStore

func NewChatStore(pool *pgxpool.Pool) *ChatStore

NewChatStore creates a new ChatStore instance

func (*ChatStore) AddChatGroupMember

func (s *ChatStore) AddChatGroupMember(ctx context.Context, groupID, userID string) error

func (*ChatStore) AddReaction

func (s *ChatStore) AddReaction(ctx context.Context, messageID, userID, reaction string) error

func (*ChatStore) BeginTx

func (s *ChatStore) BeginTx(ctx context.Context) (store.Transaction, error)

BeginTx starts a new database transaction

func (*ChatStore) CreateChatGroup

func (s *ChatStore) CreateChatGroup(ctx context.Context, group types.ChatGroup) (string, error)

func (*ChatStore) CreateChatMessage

func (s *ChatStore) CreateChatMessage(ctx context.Context, message types.ChatMessage) (string, error)

func (*ChatStore) DeleteChatGroup

func (s *ChatStore) DeleteChatGroup(ctx context.Context, groupID string) error

func (*ChatStore) DeleteChatMessage

func (s *ChatStore) DeleteChatMessage(ctx context.Context, messageID string) error

func (*ChatStore) GetChatGroup

func (s *ChatStore) GetChatGroup(ctx context.Context, groupID string) (*types.ChatGroup, error)

func (*ChatStore) GetChatMessageByID

func (s *ChatStore) GetChatMessageByID(ctx context.Context, messageID string) (*types.ChatMessage, error)

func (*ChatStore) GetUserByID

func (s *ChatStore) GetUserByID(ctx context.Context, userID string) (*types.User, error)

GetUserByID retrieves a user by ID This method is added to support tests and interfaces, but user operations should be performed through UserStore

func (*ChatStore) ListChatGroupMembers

func (s *ChatStore) ListChatGroupMembers(ctx context.Context, groupID string) ([]types.UserResponse, error)

func (*ChatStore) ListChatGroupsByTrip

func (s *ChatStore) ListChatGroupsByTrip(ctx context.Context, tripID string, limit, offset int) (*types.ChatGroupPaginatedResponse, error)

func (*ChatStore) ListChatMessageReactions

func (s *ChatStore) ListChatMessageReactions(ctx context.Context, messageID string) ([]types.ChatMessageReaction, error)

func (*ChatStore) ListChatMessages

func (s *ChatStore) ListChatMessages(ctx context.Context, groupID string, params types.PaginationParams) ([]types.ChatMessage, int, error)

func (*ChatStore) RemoveChatGroupMember

func (s *ChatStore) RemoveChatGroupMember(ctx context.Context, groupID, userID string) error

func (*ChatStore) RemoveReaction

func (s *ChatStore) RemoveReaction(ctx context.Context, messageID, userID, reaction string) error

func (*ChatStore) UpdateChatGroup

func (s *ChatStore) UpdateChatGroup(ctx context.Context, groupID string, update types.ChatGroupUpdateRequest) error

func (*ChatStore) UpdateChatMessage

func (s *ChatStore) UpdateChatMessage(ctx context.Context, messageID string, content string) error

func (*ChatStore) UpdateLastReadMessage

func (s *ChatStore) UpdateLastReadMessage(ctx context.Context, groupID, userID, messageID string) error

type LocationStore

type LocationStore struct {
	// contains filtered or unexported fields
}

func (*LocationStore) BeginTx

func (s *LocationStore) BeginTx(ctx context.Context) (store.Transaction, error)

func (*LocationStore) CreateLocation

func (s *LocationStore) CreateLocation(ctx context.Context, location *types.Location) (string, error)

func (*LocationStore) DeleteLocation

func (s *LocationStore) DeleteLocation(ctx context.Context, id string) error

func (*LocationStore) GetLocation

func (s *LocationStore) GetLocation(ctx context.Context, id string) (*types.Location, error)

func (*LocationStore) ListTripMemberLocations

func (s *LocationStore) ListTripMemberLocations(ctx context.Context, tripID string) ([]*types.MemberLocation, error)

func (*LocationStore) UpdateLocation

func (s *LocationStore) UpdateLocation(ctx context.Context, id string, update *types.LocationUpdate) (*types.Location, error)

type TodoStore

type TodoStore struct {
	// contains filtered or unexported fields
}

TodoStore implements the store.TodoStore interface using PostgreSQL

func NewTodoStore

func NewTodoStore(pool *pgxpool.Pool) *TodoStore

NewTodoStore creates a new TodoStore instance

func (*TodoStore) BeginTx

func (s *TodoStore) BeginTx(ctx context.Context) (store.Transaction, error)

BeginTx starts a new database transaction

func (*TodoStore) CreateTodo

func (s *TodoStore) CreateTodo(ctx context.Context, todo *types.Todo) (string, error)

CreateTodo creates a new todo item in the database

func (*TodoStore) DeleteTodo

func (s *TodoStore) DeleteTodo(ctx context.Context, id string) error

DeleteTodo removes a todo item from the database (soft delete)

func (*TodoStore) GetTodo

func (s *TodoStore) GetTodo(ctx context.Context, id string) (*types.Todo, error)

GetTodo retrieves a todo item by its ID

func (*TodoStore) ListTodos

func (s *TodoStore) ListTodos(ctx context.Context, tripID string) ([]*types.Todo, error)

ListTodos retrieves all todos for a specific trip

func (*TodoStore) UpdateTodo

func (s *TodoStore) UpdateTodo(ctx context.Context, id string, update *types.TodoUpdate) (*types.Todo, error)

UpdateTodo updates an existing todo item

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

Transaction wraps a pgx.Tx to implement store.Transaction

func (*Transaction) Commit

func (t *Transaction) Commit() error

func (*Transaction) Rollback

func (t *Transaction) Rollback() error

type UserStore

type UserStore struct {
	// contains filtered or unexported fields
}

UserStore implements the store.UserStore interface for PostgreSQL.

func NewUserStore

func NewUserStore(pool *pgxpool.Pool, supabaseURL, supabaseKey string) *UserStore

NewUserStore creates a new instance of UserStore

func (*UserStore) BeginTx

BeginTx starts a transaction

func (*UserStore) Commit

func (s *UserStore) Commit() error

Commit commits the transaction

func (*UserStore) ConvertToUserResponse

func (s *UserStore) ConvertToUserResponse(user *types.User) (types.UserResponse, error)

ConvertToUserResponse converts a User model to UserResponse for API responses

func (*UserStore) CreateUser

func (s *UserStore) CreateUser(ctx context.Context, user *types.User) (string, error)

CreateUser creates a new user

func (*UserStore) GetPool

func (s *UserStore) GetPool() *pgxpool.Pool

GetPool returns the underlying connection pool

func (*UserStore) GetSupabaseUser

func (s *UserStore) GetSupabaseUser(ctx context.Context, userID string) (*types.SupabaseUser, error)

GetSupabaseUser fetches a user directly from Supabase

func (*UserStore) GetUserByEmail

func (s *UserStore) GetUserByEmail(ctx context.Context, email string) (*types.User, error)

GetUserByEmail retrieves a user by their email address

func (*UserStore) GetUserByID

func (s *UserStore) GetUserByID(ctx context.Context, userID string) (*types.User, error)

GetUserByID retrieves a user by their ID

func (*UserStore) GetUserBySupabaseID

func (s *UserStore) GetUserBySupabaseID(ctx context.Context, supabaseID string) (*types.User, error)

GetUserBySupabaseID retrieves a user by their Supabase ID

func (*UserStore) GetUserProfile

func (s *UserStore) GetUserProfile(ctx context.Context, userID string) (*types.UserProfile, error)

GetUserProfile retrieves a user profile with minimal information for display

func (*UserStore) GetUserProfiles

func (s *UserStore) GetUserProfiles(ctx context.Context, userIDs []string) (map[string]*types.UserProfile, error)

GetUserProfiles retrieves multiple user profiles by their IDs

func (*UserStore) ListUsers

func (s *UserStore) ListUsers(ctx context.Context, offset, limit int) ([]*types.User, int, error)

ListUsers retrieves a paginated list of users

func (*UserStore) Rollback

func (s *UserStore) Rollback() error

Rollback aborts the transaction

func (*UserStore) SetOnlineStatus

func (s *UserStore) SetOnlineStatus(ctx context.Context, userID string, isOnline bool) error

SetOnlineStatus sets a user's online status

func (*UserStore) SyncUserFromSupabase

func (s *UserStore) SyncUserFromSupabase(ctx context.Context, supabaseID string) (*types.User, error)

SyncUserFromSupabase fetches user data from Supabase and syncs it with the local database

func (*UserStore) UpdateLastSeen

func (s *UserStore) UpdateLastSeen(ctx context.Context, userID string) error

UpdateLastSeen updates a user's last seen timestamp

func (*UserStore) UpdateUser

func (s *UserStore) UpdateUser(ctx context.Context, userID string, updates map[string]interface{}) (*types.User, error)

UpdateUser updates an existing user

func (*UserStore) UpdateUserPreferences

func (s *UserStore) UpdateUserPreferences(ctx context.Context, userID string, preferences map[string]interface{}) error

UpdateUserPreferences updates a user's preferences stored as JSON

Jump to

Keyboard shortcuts

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