Facebook Pixel

Why is there a compound index on (fromUserId, toUserId) in ConnectionRequest?

It prevents duplicate swipe attempts (a user cannot swipe on the same target twice) and speeds up the most common query: "did A already swipe on B?" Compound unique indexes serve both integrity and performance.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in DevTinder Database Schema Overview

User, ConnectionRequest, Connection (match), Message, Payment, and Subscription. Each handles a specific module: users, swipes, matches, chat, payments, and plan status.

A unique index on (user1Id, user2Id) where user1Id < user2Id ordering. This makes a match between A and B have one canonical form, so two requests cannot create the same match.

Embedded arrays grow documents unboundedly. MongoDB has a 16MB document limit, and large arrays slow down every read. Refs keep documents small and let you paginate.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.