Try Luminaweb in the browser.
A live capsule. The source is the same source. Reload to reset state.
loading capsule
server/index.ts
client/index.tsx
shared/todo.ts
import { boolean, capsule, mutation, query, string, table } from "@luminaweb/runtime/server";
export default capsule({
schema: {
todos: table({
text: string(),
done: boolean(),
ownerId: string(),
}),
},
queries: {
todos: query((ctx) =>
ctx.db.todos.where("ownerId", ctx.auth.userId).all(),
),
},
mutations: {
addTodo: mutation((ctx, text: string) => {
ctx.db.todos.insert({ text, done: false, ownerId: ctx.auth.userId });
}),
},
});