diff --git a/index.ts b/index.ts --- a/index.ts +++ b/index.ts @@ -92,19 +92,18 @@ Effect.withSpan("TodoRepository.list"), ), get, - create: (input) => - Effect.gen(function* () { - const timestamp = now(); - const todo: Todo = { - id: crypto.randomUUID(), - title: input.title, - completed: input.completed ?? false, - createdAt: timestamp, - updatedAt: timestamp, - }; - yield* Ref.update(todos, (store) => new Map(store).set(todo.id, todo)); - return todo; - }).pipe(Effect.withSpan("TodoRepository.create")), + create: Effect.fn("TodoRepository.create")(function* (input) { + const timestamp = now(); + const todo: Todo = { + id: crypto.randomUUID(), + title: input.title, + completed: input.completed ?? false, + createdAt: timestamp, + updatedAt: timestamp, + }; + yield* Ref.update(todos, (store) => new Map(store).set(todo.id, todo)); + return todo; + }), update: (id, input) => Effect.gen(function* () { const existing = yield* get(id);