Skip to content

Commit

Permalink
Increment read count & remove authorIp
Browse files Browse the repository at this point in the history
  • Loading branch information
Yureien committed Jun 8, 2023
1 parent 3dcfde1 commit bd40c5f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:
- You are about to drop the column `authorIp` on the `Paste` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Paste" DROP COLUMN "authorIp";
1 change: 0 additions & 1 deletion src/lib/server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ model Paste {
id BigInt @id @default(autoincrement())
createdAt DateTime @default(now())
key String @unique
authorIp String
content String
encrypted Boolean @default(false)
language String @default("plaintext")
Expand Down
5 changes: 5 additions & 0 deletions src/routes/[key]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export async function load({ params }) {

if (!data) throw error(404, 'Not found');

await prisma.paste.update({
where: { key },
data: { readCount: { increment: 1 } }
});

let { content, language, encrypted } = data;

let contentHtml: string;
Expand Down
1 change: 0 additions & 1 deletion src/routes/api/create/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export async function POST({ request, getClientAddress }) {
await prisma.paste.create({
data: {
key,
authorIp: getClientAddress(),
content,
language: config.language,
encrypted: config.encrypted
Expand Down

0 comments on commit bd40c5f

Please sign in to comment.