Facebook Pixel

How are relationships modeled in DevTinder?

Using ObjectId references (ref) in Mongoose. ConnectionRequest references two users (fromUserId, toUserId). Message references sender and receiver. Use populate() to fetch the full user document when needed.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in DevTinder Database Design and Schema MongoDB Collections and Relationships

Three collections: users (user profiles with name, email, password, photo, skills, about), connectionrequests (connection requests with from, to, status), and messages (chat messages with sender, receiver, text).

The compound unique index on fromUserId and toUserId prevents duplicate connection requests between the same pair of users at the database level, ensuring data integrity even if the application logic fails.

A compound index on senderId, receiverId, and createdAt (descending). This optimizes the most common query fetching message history between two users in reverse chronological order with pagination.

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.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.