Updated lib
This commit is contained in:
@@ -29,6 +29,7 @@ import { Input } from "@/components/ui/input"
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
||||
import { deleteUrl } from "@/lib/actions/url"
|
||||
import { urls } from "@/lib/drizzle/schema"
|
||||
import Link from "next/link"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { toast } from "sonner"
|
||||
|
||||
@@ -67,7 +68,9 @@ export const columns: ColumnDef<UrlRecord>[] = [
|
||||
const url = row.getValue("url") as string
|
||||
return (
|
||||
<div className="max-w-[300px] truncate" title={url}>
|
||||
{url}
|
||||
<Link href={url}>
|
||||
{url.replace(/^(https?:\/\/)/, "")}
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { eq, desc } from "drizzle-orm";
|
||||
import { eq, desc, count } from "drizzle-orm";
|
||||
import { db } from "../drizzle/db";
|
||||
import { urls, visits } from "../drizzle/schema";
|
||||
|
||||
@@ -14,6 +14,10 @@ export function getUrlBySlug(slug: string) {
|
||||
})
|
||||
}
|
||||
|
||||
export function getVisitsBySlugById(id: string) {
|
||||
return db.select({ count: count() }).from(visits).where(eq(visits.urlId, id))
|
||||
}
|
||||
|
||||
export function insertUrl(data: typeof urls.$inferInsert) {
|
||||
return db.insert(urls).values(data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user