leerob / site

My site built with Next.js, Tailwind, and Vercel.

Home Page:https://leerob.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

View Counter with planetscale

vahidtakro opened this issue · comments

I get this error while opening my url:
https://www.myurl.com/api/views:

{"message":"target: newdatabase.-.primary: vttablet: rpc error: code = NotFound desc = Table 'newdatabase.views' doesn't exist (errno 1146) (sqlstate 42S02) (CallerID: unsecure_grpc_client): Sql: \"select SUM(count) as total from views\", BindVars: {}"}

Calkpture

I just figured out I didn't add tables and columns, I found out how to create tables through this youtube video (thanks for that), but still I don't know what tables and rows should I create.
something like this:

CREATE TABLE `views` (
  `count` varchar(255) NOT NULL
);

but what values?

CREATE TABLE `views` (
`slug` varchar(128) NOT NULL,
`count` bigint NOT NULL DEFAULT '1',
PRIMARY KEY (`slug`)
)

CREATE TABLE `guestbook` (
`id` bigint NOT NULL AUTO_INCREMENT,
`email` varchar(256) NOT NULL,
`body` varchar(500) NOT NULL,
`created_by` varchar(256) NOT NULL,
`created_at` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
`updated_at` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
PRIMARY KEY (`id`)
)

I'll add this to the post!

Thanks! but unfortunately this didn't fix the issue :(
I can at least get 200 on checkly, but null.
and my posts are still showing --- instead of view numbers.

kjCalkpture

Capkkture

It doesn't seem like you have the same setup as me, so I'm not sure what is going on there.