Skip to main content

createActionItemLoader

API Docs


Function: createActionItemLoader()

createActionItemLoader(db, cache): DataLoader<string, { assignedAt: Date; categoryId: string | null; completionAt: Date | null; createdAt: Date; creatorId: string | null; eventId: string | null; id: string; isCompleted: boolean; isTemplate: boolean | null; organizationId: string; postCompletionNotes: string | null; preCompletionNotes: string | null; recurringEventInstanceId: string | null; updatedAt: Date | null; updaterId: string | null; volunteerGroupId: string | null; volunteerId: string | null; } | null, string>

Defined in: src/utilities/dataloaders/actionItemLoader.ts:30

Creates a DataLoader for batching action item lookups by ID. When a cache service is provided, wraps the batch function with cache-first logic.

Parameters

db

DrizzleClient

The Drizzle client instance for database operations.

cache

Optional cache service for cache-first lookups. Pass null to disable caching.

CacheService | null

Returns

DataLoader<string, { assignedAt: Date; categoryId: string | null; completionAt: Date | null; createdAt: Date; creatorId: string | null; eventId: string | null; id: string; isCompleted: boolean; isTemplate: boolean | null; organizationId: string; postCompletionNotes: string | null; preCompletionNotes: string | null; recurringEventInstanceId: string | null; updatedAt: Date | null; updaterId: string | null; volunteerGroupId: string | null; volunteerId: string | null; } | null, string>

A DataLoader that batches and caches action item lookups within a single request.

Example

const actionItemLoader = createActionItemLoader(drizzleClient, cacheService);
const actionItem = await actionItemLoader.load(actionItemId);