View Counter with planetscale
vahidtakro opened this issue · comments
Vahid Takro commented
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: {}"}
Vahid Takro commented
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?
Lee Robinson commented
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!
Vahid Takro commented
Lee Robinson commented
It doesn't seem like you have the same setup as me, so I'm not sure what is going on there.