Added edit page
This commit is contained in:
@@ -27,26 +27,30 @@ export async function getUrlBySlug(slug: string) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function insertUrl(data: typeof urls.$inferInsert) {
|
||||
export async function getUrlById(id: string) {
|
||||
"use cache"
|
||||
|
||||
revalidateTag("url")
|
||||
cacheTag("urls")
|
||||
|
||||
return await db.query.urls.findFirst({
|
||||
where: eq(urls.id, id)
|
||||
})
|
||||
}
|
||||
|
||||
export async function insertUrl(data: typeof urls.$inferInsert) {
|
||||
revalidateTag("urls")
|
||||
|
||||
return await db.insert(urls).values(data)
|
||||
}
|
||||
|
||||
export async function updateUrl(id: string, data: Omit<Partial<typeof urls.$inferInsert>, "id">) {
|
||||
"use cache"
|
||||
|
||||
revalidateTag("url")
|
||||
revalidateTag("urls")
|
||||
|
||||
return await db.update(urls).set(data).where(eq(urls.id, id))
|
||||
}
|
||||
|
||||
export async function deleteUrl(id: string) {
|
||||
"use cache"
|
||||
|
||||
revalidateTag("url")
|
||||
revalidateTag("urls")
|
||||
|
||||
return await db.delete(urls).where(eq(urls.id, id))
|
||||
}
|
||||
@@ -60,8 +64,6 @@ export async function getVisitsBySlugById(id: string) {
|
||||
}
|
||||
|
||||
export async function trackVisit(data: typeof visits.$inferInsert) {
|
||||
"use cache"
|
||||
|
||||
revalidateTag("visits")
|
||||
|
||||
return await db.insert(visits).values(data)
|
||||
|
||||
Reference in New Issue
Block a user