Super simple, typesafe DynamoDB query builder.
pnpm install tunisia
yarn add tunisia
npm install tunisia
import { Client } from "tunisia";
const client = new Client({
// Client options (region, credentials, etc.)
});
type Person = {
id: string;
firstName: string;
age: number;
};
const personTable = client.defineTable<Person>("tunisia_persons");
const item = {
id: "ab7bc4d5-45a8-4de2-b1da-0f274a0f6c0a",
firstName: "Jess",
age: 32,
};
await personTable.put().one(item);
const item = await personTable.query(({ eq }) => eq("id", "abc")).first();
await personTable.update().set("name", "Updated").one("id", "abc");
await personTable.delete().one("id", "abc");
const iterator = tunisia
.query(({ eq }) => eq("id", "abc"))
.index("secondary-index")
.iter();
for await (const { items } of iterator) {
console.log(items);
}
const count = tunisia
.query(({ eq }) => eq("id", "abc"))
.index("secondary-index")
.count();