/** * MongoDB Index Management * * Register and create indexes declaratively. * Extracted from mongo.ts — pure code movement. */ export interface IndexDefinition { /** Collection name */ collection: string; /** Fields and sort direction (1 = asc, -1 = desc) */ fields: Record; /** Create a unique constraint */ unique?: boolean; /** Sparse index (only index docs that have the field) */ sparse?: boolean; /** TTL index — auto-delete documents after N seconds */ expireAfterSeconds?: number; } /** * Register an index to be created when ensureIndexes() is called. * Call this at module load time to declare your indexes alongside your queries. * * ```typescript * registerIndex({ collection: 'users', fields: { email: 1 }, unique: true }); * registerIndex({ collection: 'sessions', fields: { userId: 1, startedAt: -1 } }); * registerIndex({ collection: 'tokens', fields: { expiresAt: 1 }, expireAfterSeconds: 0 }); * ``` */ export declare function registerIndex(definition: IndexDefinition): void; /** * Create all registered indexes. * Call once at application startup. Safe to call multiple times — * MongoDB skips indexes that already exist. * * ```typescript * // In your app startup: * import { ensureIndexes } from '@/core/db/index.js'; * await ensureIndexes(); // creates all registered indexes * await ensureIndexes({ dryRun: true }); // just logs what would be created * ``` */ export declare function ensureIndexes(options?: { dryRun?: boolean; }): Promise<{ created: string[]; skipped: string[]; }>; //# sourceMappingURL=mongo-indexes.d.ts.map