Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
@Schema({ timestamps: true, collection: 'analytics_cubes' })
export class AnalyticalCube extends Document {
@Prop({ type: MongooseSchema.Types.ObjectId, required: true })
tenantId: MongooseSchema.Types.ObjectId;
@Prop({ required: true, index: true })
dimensionDate: string; // YYYY-MM-DD
@Prop({ required: true, index: true })
dimensionBranch: string; // 'North' | 'South' | 'All'
@Prop({ required: true, index: true })
dimensionDepartment: string; // 'Operations' | 'Sales' | 'HR' | 'Finance'
// Facts measures
@Prop({ default: 0 }) salesTotalMinor: number;
@Prop({ default: 0 }) activeOpportunitiesCount: number;
@Prop({ default: 0 }) qualityDefectsCount: number;
@Prop({ default: 0 }) logisticsOnTimeRate: number; // percentage e.g. 98.4
}
export const AnalyticalCubeSchema = SchemaFactory.createForClass(AnalyticalCube);
AnalyticalCubeSchema.index({ tenantId: 1, dimensionDate: 1, dimensionBranch: 1, dimensionDepartment: 1 }, { unique: true });
|