butler/internal/modules/storage/postgres/postgres.go

37 lines
700 B
Go
Raw Normal View History

2023-08-13 14:06:28 +00:00
package postgres
import (
"context"
"database/sql"
_ "github.com/lib/pq"
"git.3crabs.ru/VLADIMIR/butler/internal/modules/storage"
)
type storagePostgres struct {
db *sql.DB
}
func NewStoragePostgres(urlConnect string) (storage.IStorage, error) {
db, err := sql.Open("postgres", urlConnect)
if err != nil {
return nil, err
}
return &storagePostgres{db: db}, nil
}
func (s *storagePostgres) GetAllUsersByChatID(ctx context.Context, chatID string) ([]storage.User, error) {
// TODO: imptement
return nil, nil
}
func (s *storagePostgres) UpsertUser(ctx context.Context, user storage.User) error {
// TODO: imptement
return nil
}
func (s *storagePostgres) Close() {
s.db.Close()
}