Add get all databases and destinations to services

This commit is contained in:
Luis Eduardo Jeréz Girón
2024-07-24 00:44:40 -06:00
parent 8b0f234c75
commit c2ef75873b
4 changed files with 44 additions and 0 deletions

View 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,
)
}

View 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;

View 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,
)
}

View 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;