optimize friends query by adding status to conenction indicies

This commit is contained in:
Christian Fehmer 2025-09-25 13:51:54 +02:00
parent 4b9e275a13
commit 71ec07a774
No known key found for this signature in database
GPG key ID: FE53784A69964062

View file

@ -195,8 +195,8 @@ function getKey(initiatorUid: string, receiverUid: string): string {
export async function createIndicies(): Promise<void> {
//index used for search
await getCollection().createIndex({ initiatorUid: 1 });
await getCollection().createIndex({ receiverUid: 1 });
await getCollection().createIndex({ initiatorUid: 1, status: 1 });
await getCollection().createIndex({ receiverUid: 1, status: 1 });
//make sure there is only one connection for each initiatorr/receiver
await getCollection().createIndex({ key: 1 }, { unique: true });