Firestore Save Documents
Tinder Firestore Swipe and Match
For each user that has registered into our system, we'll have to insert a record into Firestore so that we can keep track of it. The idea is fairly similar to Firebase Database, but the syntax is a little different. We'll walkthrough how to save document objects and examine at the Firebase console for changes.

Comments (20)
Vijayferrari
4 years ago
Hey Brian, I am wondering what the big differences are between the Realtime Database and Cloud Firestore. Which one is better for bigger apps with a lot of users? Also, I currently use the Realtime Database for one of my apps and I want to use Cloud Firestore but I was wondering if there was any easy way to move existing data from the Realtime Database to Cloud Firestore. Thanks!
Brian Voong
4 years ago
Vijayferrari
4 years ago
Thanks for the info!
flashtrend
4 years ago
Hi Brian, I have been following along the tinder videos and I like the new Firestore datebase. I was wondering if it would be possible to follow along the Instagram videos while attempting to use Firestore rather than RTDB. Would that be possible or would it be too hard to follow.
Govind K Kara
4 years ago
Hi Brian, which mode(locked/test) to select while we setting up the fire store?
Brian Voong
4 years ago
Govind K Kara
4 years ago
Oh as you said we have to use the auth required mode.I figured it out
Yogin
4 years ago
Hi, why are all the images being download in .dms file?
Brian Voong
4 years ago
Yogin
4 years ago
Thanks a lot :)
Tube
4 years ago
If you download an uploaded image, it will come back as a .dms file. To avoid this, set the metadata like this: let metaData = StorageMetadata() metaData.contentType = “image/jpeg" ref.putData(imageData, metadata: metaData, completion: BTW You should post and check for answers in the Comments section of the lesson where the code is, and not in the following lesson.
Cinquain
4 years ago
You have to put image/jpeg as a metadata in the metadata block when you upload to firestore.
Tube
4 years ago
If you live in a country which blocks all or part (Database) of Firebase, you will need to use a VPN which supports OpenVPN stealth mode. Basically, this uses https to hide the packet contents. The symptom may be that the Firebase call never returns to your app.
yuiso
4 years ago
Hi Tube, can you be more specific? Do you mean that I need to use a Open vpn tool
yuiso
4 years ago
I'm using a Shadowsocks server and I can access youtube/google/ and the google firestore website. but still can't access Firestore.firestore().collection("users").document(uid).setData(docData)
Tube
4 years ago
I use a commercial VPN which provides me a VPN app to make the VPN connection. When I choose a server in that app, I must select one with an Open VPN stealth mode. Commercial VPNs often apply only to the browser, so you can visit Web sites. Open VPN should apply to all your Mac apps, including the Xcode simulator. That's all I know about it.
Cinquain
4 years ago
That video was fire!
0zgur
4 years ago
Go in Database -> Rules -> Change allow read, write: if false; to true;
ericathanas
4 years ago
Thank you!
dclawson
4 years ago
I'm not admitting to anything, but be careful with code completion when choosing "saveInfoToFirestore" that you don't enter "saveInfoToFirebase", especially within the "saveInfoToFirebase" function. If you do, your app will happily run in the background, silently creating an endless number of images on your Firebase instance.
fishercraigj
4 years ago
haha....totally did it. :) Luckily I saw it looping in the console before it got out of control. In regards to you're earlier Firestore warning, I'm getting them and today is 2/28/19.
ndevereaux
4 years ago
This saved me about 20 minutes of trying to figure out why my stuff wasn't saving haha.
serxhio
4 years ago
Dude I did the same, thanks to the console and your comment, I figured it out lol
Eugeneberezin
4 years ago
I wish I saw your comment before my Firebase started blowing up lol. Thank you.
dclawson
4 years ago
For what it's worth, I'm using the latest (as of 2/21/19) versions of the pods, and I didn't get the warning that Brian talks about at the end.
fishercraigj
4 years ago
You're probably just pulling the latest and greatest Firebase pods I assume? I'm using the exact pods he called out in the videos. Good to know the warnings go away though!
fishercraigj
4 years ago
Hey Brian - Total nit but you're messing with my OCD dude. Every time I finish a video the web page says 93%, 98%, 96% completed. You'd be shocked how many times I've reopened a video just to fast forward to the end and try to make it set at 100% Man I've got issues...
Brian Voong
4 years ago
dclawson
4 years ago
Maybe it's my training as a Mechanical Engineer, but I figured that my goal for each lesson was: 100% +/- 3% :-)
dclawson
4 years ago
Maybe it's my training as a Mechanical Engineer, but I figured that my goal for each lesson was: 100% +/- 3% :-)
Velkei Miklós
4 years ago
Hi! I got the following error: "firestore Missing or insufficient permissions." To fix it in the database rules section, you need to modify the false to true: service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write: if true; } } } I hope it will help some one the next time:)
richardbranson
4 years ago
completion(nil) show error -> Nil is not compatible with expected argument type 'Error'
richardbranson
4 years ago
Competion: (Error?)
Rizul Sharma
3 years ago
This is also not working for me can you please elaborate. ?
richardbranson
4 years ago
[Firebase/Firestore][I-FST000001] Write at users/oxPpMiSxUae11KiQ9cs8XnqMf3z1 failed: Missing or insufficient permissions.
richardbranson
4 years ago
go to database rule and read write if false change true
kestelle
4 years ago
I keep getting a "Failed registration, check server response" if anyone could help with this. I'd be super grateful!!
jtcreed@outlook.com
4 years ago
Did you manage to find a solution? Regards, John
Brian Voong
4 years ago
jtcreed@outlook.com
4 years ago
Brian - Thank you very much for your reply. I'm afraid I've tried utilising a VPN connection with no success. I successfully register my user onto firebase, but the "Failed registration, check server response" error still appears; therefore not saving onto the database.
sraffe
4 years ago
Did you go into the storage tab on your Firebase page? You need to confirm a form or two on that page before you can perform the hits.
jtcreed@outlook.com
4 years ago
Hi Sraffe, Thank you so much, this has solved the problem. I'm an absolute beginner to Firebase. Much appreciated.
Dongjun Kim
4 years ago
Hi! Brian I really like your lessons about firestore but you should've let us know the guide for website of firestore first! I spent pretty much time for fixing some problems but it was just things on website. Thank you
Eugeneberezin
4 years ago
Hey Brian, I am not able to see users in my database. I don't see any errors in the log either. My Firebase rules: rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write: if true; } } }
Eugeneberezin
4 years ago
Looks like I fixed the issue. Just needed to put it out there.
Eugeneberezin
4 years ago
Another thing that I've noticed after I finished registering my user the call to create a new user is being executed over and over again. It kinda creates an infinite loop.
Eugeneberezin
4 years ago
Correction. The user is just 1. However, somehow I see 150 images for that user. Can't quite figure out why it's happening.
Brian Voong
4 years ago
Eugeneberezin
4 years ago
Hahahaha. Very interesting bug. Thank you for your help. I be like WHY my Firebase is blowing up?!!?! Did I uploaded it to the AppStore by mistake and forgot about it lol. Thank you
Rizul Sharma
3 years ago
Hi Brian!! Awesome course so far, thanks for that. I am getting a error in , completion(nil) -> 'nil' is not compatible with expected argument type 'Error' Brian or anyone please help.!
Brian Voong
3 years ago
Rizul Sharma
3 years ago
Thank you so much Brian for such a quick response.!! Much appreciated.
Omran_K
3 years ago
Started getting this error today when I came back to continue the course: UIImagePickerController extension discovery failed with error: (null) It was working fine last week. Any idea what this is?
Dino32
3 years ago
Hi Brian, The Project Download button is broken. When I've tapped upon it the login screen is appeared instead of downloading page.
Brian Voong
3 years ago
HELP & SUPPORT