I am trying to wrap my head around this so here goes.. Can I use firebase authentication with mongodb? I am trying to build a sort of message board using the mern stack and I hate dealing with authentication. How would I store the user in mongodb and have linked to for example a certain comment that was left by them? I just need some direction or possible some alternatives. Thanks
1 Answer
This is just a completely basic answer, many people do have a lot more knowledge about this than me. But, to answer your question: yes, you can use firebase authentication with MongoDB. When a person is making a user on your page, you can easily make a document inside MongoDB where all the user's data is stored. When you want to link your user to a comment, your database may look something like this:
Comments (collection) - 'random id' - user: 'firebase uid', comment: 'Hello world!', timestamp: '6th of March, 20:24' (document)
- 'random id2' - user: 'firebase uid', comment: 'Hello StackOverflow!', timestamp: '2nd of March, 23:59' (document)
You could of course design your database otherwise, and there is 100% a much more effective way, but this will hopefully give you a direction to where to start.
I assume you somewhat know how to use MongoDB and Firebase Authentication.