mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-01-25 05:58:29 -06:00
Add get all databases and destinations to services
This commit is contained in:
15
internal/service/databases/get_all_databases.go
Normal file
15
internal/service/databases/get_all_databases.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package databases
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/eduardolat/pgbackweb/internal/database/dbgen"
|
||||
)
|
||||
|
||||
func (s *Service) GetAllDatabases(
|
||||
ctx context.Context,
|
||||
) (dbgen.DatabasesServiceGetAllDatabasesRow, error) {
|
||||
return s.dbgen.DatabasesServiceGetAllDatabases(
|
||||
ctx, *s.env.PBW_ENCRYPTION_KEY,
|
||||
)
|
||||
}
|
||||
6
internal/service/databases/get_all_databases.sql
Normal file
6
internal/service/databases/get_all_databases.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
-- name: DatabasesServiceGetAllDatabases :one
|
||||
SELECT
|
||||
*,
|
||||
pgp_sym_decrypt(connection_string, @encryption_key) AS decrypted_connection_string
|
||||
FROM databases
|
||||
ORDER BY created_at DESC;
|
||||
16
internal/service/destinations/get_all_destinations.go
Normal file
16
internal/service/destinations/get_all_destinations.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package destinations
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/eduardolat/pgbackweb/internal/database/dbgen"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func (s *Service) GetAllDestinations(
|
||||
ctx context.Context, id uuid.UUID,
|
||||
) (dbgen.DestinationsServiceGetAllDestinationsRow, error) {
|
||||
return s.dbgen.DestinationsServiceGetAllDestinations(
|
||||
ctx, *s.env.PBW_ENCRYPTION_KEY,
|
||||
)
|
||||
}
|
||||
7
internal/service/destinations/get_all_destinations.sql
Normal file
7
internal/service/destinations/get_all_destinations.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
-- name: DestinationsServiceGetAllDestinations :one
|
||||
SELECT
|
||||
*,
|
||||
pgp_sym_decrypt(access_key, @encryption_key) AS decrypted_access_key,
|
||||
pgp_sym_decrypt(secret_key, @encryption_key) AS decrypted_secret_key
|
||||
FROM destinations
|
||||
ORDER BY created_at DESC;
|
||||
Reference in New Issue
Block a user