Skip to content

Instantly share code, notes, and snippets.

@martpet
martpet / db.js
Created December 19, 2023 19:29
Deno KV secondary index
export async function setUser(user) {
const primaryKey = ["users", user.id];
const byColorKey = ["users_by_favorite_color", user.favoriteColor, user.id];
const oldUser = await getUser(user.id);
const atomic = kv.atomic();
if (oldUser) {
if (oldUser.favoriteColor !== user.favoriteColor) {
@martpet
martpet / deno-indexes.ts
Last active June 15, 2023 08:08
Unique and non-unique indexes with Deno KV
const kv = await Deno.openKv();
interface Choice {
id: string;
poll: string;
title: string;
}
export async function setChoice(choice: Choice) {
const primaryKey = ["choices", choice.id];
@martpet
martpet / template.json
Created July 20, 2022 14:29
Cfn template
{
"Resources": {
"ZoneHostedZoneB23BB523": {
"Type": "AWS::Route53::HostedZone",
"Properties": {
"Name": "martin.dev.trip.pictures."
},
"Metadata": {
"aws:cdk:path": "TripPics/Zone/HostedZone/Resource"
}