Create type-safe Drizzle queries for database operations
Generate type-safe Drizzle ORM queries for CRUD operations with proper error handling, relations, and TypeScript inference.
/plugin marketplace add marcioaltoe/claude-craftkit/plugin install db-tools@claude-craftkitGenerate type-safe Drizzle ORM queries for CRUD operations.
const result = await db.query.users.findFirst({
where: eq(users.id, userId),
with: {
posts: true,
profile: true,
},
});
const [newUser] = await db.insert(users).values({ name, email }).returning();
await db.transaction(async (tx) => {
await tx.insert(users).values(userData);
await tx.insert(profiles).values(profileData);
});
Ensure proper error handling and type safety throughout.