aggregation optimization

This commit is contained in:
Emily
2024-09-02 18:37:02 +02:00
parent c003b655ec
commit 023f2b5f4a
3 changed files with 15 additions and 20 deletions

View File

@@ -36,8 +36,10 @@ const VisitSchema = new Schema<TVisit>({
website: { type: String, required: true },
page: { type: String, required: true },
referrer: { type: String, required: true },
created_at: { type: Date, default: () => Date.now(), index: true },
created_at: { type: Date, default: () => Date.now() },
})
VisitSchema.index({ project_id: 1, created_at: -1 });
export const VisitModel = model<TVisit>('visits', VisitSchema);