Solo Project Day Seven: To The Database and Back Again
This is technically the eighth day since I began my solo project, but I didn’t do any work on the project on Sunday (although I did do some other web work.
Today was a very productive day for me. I got more done than I expected to, and I made it to MVP (Minimum Viable Product)! I didn’t think I’d get to MVP this fast, but I’m glad I did. At Prime, we all get industry mentors to work with, and tomorrow we meet with them to show them our solo projects. I was really hoping I’d have a usable product to show them.
- Sorted out asynchronous tasks on the login page so that writing data returned from Firebase to the database happened after the data was actually received.
- Figured out how to use
$locationto redirect to a new page after login:
- This one was a doozie. I figured out how to create a new blank Mongoose sub-document upon the press of the “new tweet” button. Here’s the code (authFactory is where I’m storing the currently logged in user’s data):
// client side
- I then figured out how to move the edited text of a draft into the database. This was also difficult, as I had to query the database for the specific draft that was being edited, and then update that one. Here’s the code:
// client side
- Lastly, I queried the database to display the current user’s drafts on the Drafts page in a list.
Tomorrow’s task will be mainly styling. I want the app to look nice for my mentors.
- getting the id of the newly pushed embedded object - Stack Overflow - I needed to get
array.length - 1). I shoulda known.
- Factory not keeping data when used in controller - Stack Overflow - This was frustrating. I initially was trying to assign objects directly to my factories, but I found that I had to assign specific values to them instead (see the first client side code example above). I still don’t know why I need to do it this way, but I know that it does work.