-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting a custom document ID in Firebase through Firestore #4
Comments
|
Okay @laniehei && @1Marc! I made a new branch called https://github.com/stevekinney/think-piece/tree/qa-modification I made the change and then cherry-picked all of the subsequent commits. That should be the safest way to do it. If it looks good to y'all, I will rename it Sorry about the delay! |
I think @laniehei links to specific commits in the annotations. So if you rename the branch, all the commit hashes she refers to in the annotations will need to be updated. If squashing the extra commit in isn't too difficult, I think that would be the best approach @stevekinney. |
Sorry for the delay—I totally missed this comment. Thanks for following up on Twitter. I squashed on the But also, I tried to reproduce the issue and I couldn't get it to error out. Everything worked. Am I missing something? |
I pushed up the combined commit and made it the |
Thanks Steve! It's interesting that you weren't able to reproduce the issue -- @1Marc cloned the branch at the point were this was written, and was able to recreate the bug on his machine that I was seeing as I was going through the course. |
I'm also working in a project where I've to used a custom I'd but that should be the one inputted by me from a form . |
Exactly the same way that were discussed above ^ |
Kind human, I don't know you but your post saved me from the darkness of going on the page "2" of google, you really are desperate when you try the second page of the google search |
When you recorded the course, this code:
firestore.collection('posts').add(post);
would use the id property as the document id in firebase. This isn't the case anymore. If you use add(), then Firebase will use a generated document ID by Firebase instead of the id you provided, causing getting the document later withfirestore.doc('posts/CUSTOMID')
to not retrieve any document.The way to resolve this and make the course code work as expected, is that you need to create a new document reference "path" with
firestore.collection('posts').doc(CUSTOMID)
and then you save it to the database with theset
method. .. so the full code would befirestore.collection('posts').doc(CUSTOMID).set(post)
and post would not contain the id in it's data since it's now the path of the document.The code we need to update was introduced in the cf06e77ad586367c0cb24ee42a2ed479f2119adc commit and will need to be updated in all subsequent branches.
The text was updated successfully, but these errors were encountered: