summaryrefslogtreecommitdiff
path: root/database/dns.go
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-03-27 22:55:22 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-03-27 22:55:22 -0600
commit75ba836d6072235fc7a71659f8630ab3c1b210ad (patch)
tree386b65ae6d7a4215c2f7b4944fc2f0922d162491 /database/dns.go
parentb2fa4fe9454cbc9c9c0e265e3e6065eaa8726e2f (diff)
downloadhatecomputers.club-75ba836d6072235fc7a71659f8630ab3c1b210ad.tar.gz
hatecomputers.club-75ba836d6072235fc7a71659f8630ab3c1b210ad.zip
add dns form
Diffstat (limited to 'database/dns.go')
-rw-r--r--database/dns.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/database/dns.go b/database/dns.go
new file mode 100644
index 0000000..17487b7
--- /dev/null
+++ b/database/dns.go
@@ -0,0 +1,40 @@
+package database
+
+import (
+ "database/sql"
+ _ "github.com/mattn/go-sqlite3"
+ "log"
+ "time"
+)
+
+type DNSRecord struct {
+ ID string
+ UserID string
+ Name string
+ Type string
+ Content string
+ TTL int
+ CreatedAt time.Time
+}
+
+func GetUserDNSRecords(db *sql.DB, userID string) ([]DNSRecord, error) {
+ log.Println("getting dns records for user", userID)
+
+ rows, err := db.Query("SELECT * FROM dns_records WHERE user_id = ?", userID)
+ if err != nil {
+ return nil, err
+ }
+ defer rows.Close()
+
+ var records []DNSRecord
+ for rows.Next() {
+ var record DNSRecord
+ err := rows.Scan(&record.ID, &record.UserID, &record.Name, &record.Type, &record.Content, &record.TTL, &record.CreatedAt)
+ if err != nil {
+ return nil, err
+ }
+ records = append(records, record)
+ }
+
+ return records, nil
+}