diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-07-07 15:20:11 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-07-07 15:52:59 +0530 |
commit | e0f32fb48caf9397ac87fdd6c6597d888f9a8a40 (patch) | |
tree | 0a9c5ccabf13192264d7967533a4d8a0ddb16529 /db | |
parent | 60aa1b7adbd133a5b1679ab2feac4ec17e3b48b5 (diff) |
api/dns: init
Diffstat (limited to 'db')
-rw-r--r-- | db/query.sql | 10 | ||||
-rw-r--r-- | db/query.sql.go | 16 |
2 files changed, 18 insertions, 8 deletions
diff --git a/db/query.sql b/db/query.sql index 9ba172f..f4b17dd 100644 --- a/db/query.sql +++ b/db/query.sql @@ -6,8 +6,7 @@ INSERT INTO Usage ( ); -- name: GetUsage :one -SELECT SUM(Ingress) AS Ingress, SUM(Egress) AS Egress -FROM Usage; +SELECT SUM(Ingress) AS Ingress, SUM(Egress) AS Egress FROM Usage; -- name: EnterDnsBlackList :exec INSERT INTO DnsBlackList ( @@ -16,6 +15,9 @@ INSERT INTO DnsBlackList ( $1 ); +-- name: DeleteDnsBlackList :exec +DELETE FROM DnsBlackList +WHERE Name = $1; + -- name: GetDnsBlackList :many -SELECT * -FROM DnsBlackList; +SELECT * FROM DnsBlackList; diff --git a/db/query.sql.go b/db/query.sql.go index 80c6469..7c28723 100644 --- a/db/query.sql.go +++ b/db/query.sql.go @@ -11,6 +11,16 @@ import ( "github.com/jackc/pgx/v5/pgtype" ) +const deleteDnsBlackList = `-- name: DeleteDnsBlackList :exec +DELETE FROM DnsBlackList +WHERE Name = $1 +` + +func (q *Queries) DeleteDnsBlackList(ctx context.Context, name string) error { + _, err := q.db.Exec(ctx, deleteDnsBlackList, name) + return err +} + const enterDnsBlackList = `-- name: EnterDnsBlackList :exec INSERT INTO DnsBlackList ( Name @@ -52,8 +62,7 @@ func (q *Queries) EnterUsage(ctx context.Context, arg EnterUsageParams) error { } const getDnsBlackList = `-- name: GetDnsBlackList :many -SELECT name -FROM DnsBlackList +SELECT name FROM DnsBlackList ` func (q *Queries) GetDnsBlackList(ctx context.Context) ([]string, error) { @@ -77,8 +86,7 @@ func (q *Queries) GetDnsBlackList(ctx context.Context) ([]string, error) { } const getUsage = `-- name: GetUsage :one -SELECT SUM(Ingress) AS Ingress, SUM(Egress) AS Egress -FROM Usage +SELECT SUM(Ingress) AS Ingress, SUM(Egress) AS Egress FROM Usage ` type GetUsageRow struct { |