mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-04-28 06:59:10 -05:00
Add get all databases and destinations to services
This commit is contained in:
@@ -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,
|
||||
)
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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,
|
||||
)
|
||||
}
|
||||
@@ -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