## CTE Utils System - Created comprehensive CTE (Common Table Expression) builder utilities - Supports declarative query building with automatic relation handling - Smart strategy selection between JOIN+GROUP BY and subquery patterns - Handles nested relations with automatic optimization - Type-safe query construction with Drizzle ORM ## Platform Users Enhancements - Refactored to use new CTE utils for cleaner query building - Added analytics middleware to Hono pipeline - Improved query param handling with queryStringArray helper - Changed timestamps from ISO strings to milliseconds for consistency - Extracted cleanOrgSlug utility function ## Other Improvements - Added analytics middleware for Hono routes - Enhanced base middleware with better context handling - Fixed template literal linting in initHono.ts - Updated logger for better structured logging - Added test files for CTE development ## File Changes - New: server/src/db/cteUtils/ - Complete CTE builder system - New: server/src/honoMiddlewares/analyticsMiddleware.ts - Modified: handleListPlatformUsers.ts - Refactored with CTE utils - Modified: platformModels.ts - Updated types and validation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
12 lines
417 B
TypeScript
12 lines
417 B
TypeScript
import { relations } from "drizzle-orm";
|
|
import { member } from "../../db/auth-schema.js";
|
|
import { apiKeys } from "../devModels/apiKeyTable.js";
|
|
import { features } from "../featureModels/featureTable.js";
|
|
import { organizations } from "./orgTable.js";
|
|
|
|
export const organizationsRelations = relations(organizations, ({ many }) => ({
|
|
api_keys: many(apiKeys),
|
|
features: many(features),
|
|
members: many(member),
|
|
}));
|