Back

"Best" way to handle Auth & User Collection

  • 0
  • Databases
  • Auth
  • Web
ghiblimagic
21 Feb, 2025, 05:14

Hi All!

I'm trying to figure out the best way to "link" Accounts and my user collection. I know I can't link them with a relationship. I appreciate your thoughts on the "best" way to handle this!

When I create a new Account user would it be best to?

  1. grab the account user's id, and set the new user documents id === account user id
  2. grab the account user's id, let the user document generate a unique id, then toss the account users id into a property on the new user document. Such as "account id"
  3. Link the 2 with a 3rd collection. User Id generates its own unique id. The third document just has 2 properties:
  4. Account id
  5. User Id

The first option seems more efficient. And if I'm not misunderstanding something, someone would need the session data/secret not just the user id to really do anything to the Auth Account right? So 2 and 3 just seems to add extra complexity?

(I'm using Next.Js 15 if that changes anyone's answer)

TL;DR
Developers are discussing the best way to link Accounts and user collection in Next.Js 15. The options considered are: 1. Linking user documents directly with the account user's id. 2. Generating a unique id for user documents and storing the account user's id in a property. 3. Using a third collection to link account id and user id. The first option is deemed more efficient as additional complexity with 2 and 3 may not be necessary.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more