mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-08-28 11:17:07 +00:00
Fix DNS record management issues by improving database interactions.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/0c00fde5-fbe2-4141-8971-e16f704e73f1.jpg
This commit is contained in:
@@ -386,26 +386,89 @@ export class DatabaseStorage implements IStorage {
|
|||||||
|
|
||||||
// DNS Record management
|
// DNS Record management
|
||||||
async getDnsRecord(id: string): Promise<DnsRecord | undefined> {
|
async getDnsRecord(id: string): Promise<DnsRecord | undefined> {
|
||||||
const [record] = await db.select().from(dnsRecords).where(eq(dnsRecords.id, id));
|
const [record] = await db.select({
|
||||||
|
id: dnsRecords.id,
|
||||||
|
domainId: dnsRecords.domainId,
|
||||||
|
name: dnsRecords.name,
|
||||||
|
type: dnsRecords.type,
|
||||||
|
content: dnsRecords.content,
|
||||||
|
ttl: dnsRecords.ttl,
|
||||||
|
isActive: dnsRecords.isActive,
|
||||||
|
isAutoIP: dnsRecords.isAutoIP,
|
||||||
|
notes: dnsRecords.notes,
|
||||||
|
providerId: dnsRecords.providerId,
|
||||||
|
lastUpdated: dnsRecords.lastUpdated,
|
||||||
|
createdAt: dnsRecords.createdAt
|
||||||
|
})
|
||||||
|
.from(dnsRecords)
|
||||||
|
.where(eq(dnsRecords.id, id));
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDnsRecordsByDomain(domainId: string): Promise<DnsRecord[]> {
|
async getDnsRecordsByDomain(domainId: string): Promise<DnsRecord[]> {
|
||||||
return await db.select()
|
return await db.select({
|
||||||
|
id: dnsRecords.id,
|
||||||
|
domainId: dnsRecords.domainId,
|
||||||
|
name: dnsRecords.name,
|
||||||
|
type: dnsRecords.type,
|
||||||
|
content: dnsRecords.content,
|
||||||
|
ttl: dnsRecords.ttl,
|
||||||
|
isActive: dnsRecords.isActive,
|
||||||
|
isAutoIP: dnsRecords.isAutoIP,
|
||||||
|
notes: dnsRecords.notes,
|
||||||
|
providerId: dnsRecords.providerId,
|
||||||
|
lastUpdated: dnsRecords.lastUpdated,
|
||||||
|
createdAt: dnsRecords.createdAt
|
||||||
|
})
|
||||||
.from(dnsRecords)
|
.from(dnsRecords)
|
||||||
.where(eq(dnsRecords.domainId, domainId));
|
.where(eq(dnsRecords.domainId, domainId));
|
||||||
}
|
}
|
||||||
|
|
||||||
async createDnsRecord(record: InsertDnsRecord): Promise<DnsRecord> {
|
async createDnsRecord(record: InsertDnsRecord): Promise<DnsRecord> {
|
||||||
const [newRecord] = await db.insert(dnsRecords).values(record).returning();
|
// Filter out the proxied field if it exists
|
||||||
|
const { proxied, ...recordData } = record as any;
|
||||||
|
|
||||||
|
// Insert the record without the proxied field
|
||||||
|
const [newRecord] = await db.insert(dnsRecords).values(recordData).returning({
|
||||||
|
id: dnsRecords.id,
|
||||||
|
domainId: dnsRecords.domainId,
|
||||||
|
name: dnsRecords.name,
|
||||||
|
type: dnsRecords.type,
|
||||||
|
content: dnsRecords.content,
|
||||||
|
ttl: dnsRecords.ttl,
|
||||||
|
isActive: dnsRecords.isActive,
|
||||||
|
isAutoIP: dnsRecords.isAutoIP,
|
||||||
|
notes: dnsRecords.notes,
|
||||||
|
providerId: dnsRecords.providerId,
|
||||||
|
lastUpdated: dnsRecords.lastUpdated,
|
||||||
|
createdAt: dnsRecords.createdAt
|
||||||
|
});
|
||||||
|
|
||||||
return newRecord;
|
return newRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateDnsRecord(id: string, recordData: Partial<InsertDnsRecord>): Promise<DnsRecord | undefined> {
|
async updateDnsRecord(id: string, recordData: Partial<InsertDnsRecord>): Promise<DnsRecord | undefined> {
|
||||||
|
// Filter out the proxied field if it exists
|
||||||
|
const { proxied, ...filteredData } = recordData as any;
|
||||||
|
|
||||||
const [updatedRecord] = await db.update(dnsRecords)
|
const [updatedRecord] = await db.update(dnsRecords)
|
||||||
.set({ ...recordData, lastUpdated: new Date() })
|
.set({ ...filteredData, lastUpdated: new Date() })
|
||||||
.where(eq(dnsRecords.id, id))
|
.where(eq(dnsRecords.id, id))
|
||||||
.returning();
|
.returning({
|
||||||
|
id: dnsRecords.id,
|
||||||
|
domainId: dnsRecords.domainId,
|
||||||
|
name: dnsRecords.name,
|
||||||
|
type: dnsRecords.type,
|
||||||
|
content: dnsRecords.content,
|
||||||
|
ttl: dnsRecords.ttl,
|
||||||
|
isActive: dnsRecords.isActive,
|
||||||
|
isAutoIP: dnsRecords.isAutoIP,
|
||||||
|
notes: dnsRecords.notes,
|
||||||
|
providerId: dnsRecords.providerId,
|
||||||
|
lastUpdated: dnsRecords.lastUpdated,
|
||||||
|
createdAt: dnsRecords.createdAt
|
||||||
|
});
|
||||||
|
|
||||||
return updatedRecord;
|
return updatedRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user