News for hackers. Stuff that matters.
Re:Adding view count and like button to 11ty by chilling on Sunday June 23, 2024 @11:15PM (#40772431)
so how would you approach this?
Re:Adding view count and like button to 11ty by porridgeraisin on Monday June 24, 2024 @12:36AM (#40772691)
Just do hincrby alone, if it doesn't exist it will automatically become 1
Re:Adding view count and like button to 11ty by chilling on Monday June 24, 2024 @01:14AM (#40772798)
You are right. It just should be like so:

Get:

   const likes = (await kv.hget(postTitle, "likes")) || 0
Post:

   const likes = await kv.hincrby(postTitle, "likes", 1);