Questions tagged [google-cloud-firestore]
Cloud Firestore is an auto-scaling real-time document database for storing, syncing, and querying data for mobile, web and server development.
google-cloud-firestore
42,535
questions
490
votes
28
answers
418k
views
No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() in Flutter and Firebase
I am building a Flutter application and I have integrated Firebase, but I keep getting this error when I click on a button either to register, login, or logout. I have seen other people have asked the ...
432
votes
6
answers
181k
views
What's the difference between Cloud Firestore and the Firebase Realtime Database?
Google just released Cloud Firestore, their new Document Database for apps.
I have been reading the documentation but I don't see a lot of differences between Firestore and Firebase DB.
The main ...
352
votes
32
answers
528k
views
firestore: PERMISSION_DENIED: Missing or insufficient permissions
I am getting the Error
gettingdocuments.com.google.firebase.firestore.FirebaseFirestoreException:
PERMISSION_DENIED: Missing or insufficient permissions.
for the below code on else statement
...
330
votes
30
answers
286k
views
Cloud Firestore collection count
Is it possible to count how many items a collection has using the new Firebase database, Cloud Firestore?
If so, how do I do that?
315
votes
9
answers
155k
views
What is Firebase Firestore 'Reference' data type good for?
I'm just exploring the new Firebase Firestore and it contains a data type called reference. It is not clear to me what this does.
Is it like foreign key?
Can it be used to point to a collection ...
310
votes
7
answers
631k
views
How can I solve the error 'TS2532: Object is possibly 'undefined'?
I'm trying to rebuild a web app example that uses Firebase Cloud Functions and Firestore. When deploying a function I get the following error:
src/index.ts:45:18 - error TS2532: Object is possibly '...
273
votes
6
answers
119k
views
Difference Between Firestore Set with {merge: true} and Update
In Cloud Firestore there are three write operations:
add()
set()
update()
In the docs it says that using set(object, { merge: true }) will merge the given object with the existing document.
The same ...
270
votes
12
answers
112k
views
Separate dev and prod Firebase environment
I am considering using Firebase as MBaaS, however I couldn't find any reliable solution to the following problem:
I would like to set up two separate Firebase environments, one for development and one ...
261
votes
35
answers
548k
views
error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class
First time using firestore and I'm getting this error. It seems to be a problem with Ivy, from my research. I don't have a lot of experience modifying tsconfig.app.json, which is the direction I've ...
214
votes
12
answers
449k
views
NullInjectorError: No provider for AngularFirestore
I'm learning Angular looking for help in fixing the error:
I'm following this link : https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md
to create a angular small app with ...
211
votes
26
answers
199k
views
How do I convert a Firestore date/Timestamp to a JS Date()?
I am trying to convert the below date to a javascript Date() object. When I get it back from the server, it is a Timestamp object,
Screenshot from Firebase Firestore console:
When I try the ...
211
votes
28
answers
162k
views
Google Firestore: Query on substring of a property value (text search)
I am looking to add a simple search field, would like to use something like
collectionRef.where('name', 'contains', 'searchTerm')
I tried using where('name', '==', '%searchTerm%'), but it didn't ...
210
votes
11
answers
214k
views
type 'List<dynamic>' is not a subtype of type 'List<Widget>'
I have a snippet of code which I copied from Firestore example:
Widget _buildBody(BuildContext context) {
return new StreamBuilder(
stream: _getEventStream(),
builder: (context, ...
206
votes
13
answers
100k
views
Flutter Firestore causing D8: Cannot fit requested classes in a single dex file (# methods: 71610 > 65536) in Android Studio
I am attempting to use firestore with a Flutter app in latest version of Android Studio. I have followed these instructions exactly. https://www.youtube.com/watch?v=DqJ_KjFzL9I&list=...
203
votes
12
answers
189k
views
How to add Document with Custom ID to firestore
Is there any chance to add a document to firestore collection with custom generated id, not the id generated by firestore engine?
199
votes
17
answers
100k
views
Google Firestore - How to get several documents by multiple ids in one round-trip?
I am wondering if it's possible to get multiple documents by a list of ids in one round trip (network call) to the Firestore database.
193
votes
18
answers
221k
views
How to update an "array of objects" with Firestore?
I'm currently trying Firestore, and I'm stuck at something very simple: "updating an array (aka a subdocument)".
My DB structure is super simple. For example:
proprietary: "John Doe",
sharedWith:
[...
192
votes
24
answers
79k
views
Error: Failed to get Firebase project project-name. Please make sure the project exists and your account has permission to access it
I tried running firebase deploy like I have always done but came across this Error:
Error: Failed to get Firebase project project-name. Please make sure the project exists and your account has ...
190
votes
11
answers
122k
views
Firestore query subcollections
I thought I read that you can query subcollections with the new Firebase Firestore, but I don't see any examples. For example I have my Firestore setup in the following way:
Dances [collection]
...
174
votes
10
answers
184k
views
Why is my React component is rendering twice?
I don't know why my React component is rendering twice. So I am pulling a phone number from params and saving it to state so I can search through Firestore. Everything seems to be working fine except ...
156
votes
11
answers
205k
views
Query firestore database for document id
I want to query a firestore database for document id. Currently I have the following code:
db.collection('books').where('id', '==', 'fK3ddutEpD2qQqRMXNW5').get()
I don't get a result. But when I ...
144
votes
14
answers
272k
views
Getting all documents from one collection in Firestore
Hi I'm starting with javascript and react-native and I'm trying to figure out this problem for hours now. Can someone explain me how to get all the documents from firestore collection ?
I have been ...
144
votes
12
answers
190k
views
Firestore query by date range
I need the help to query long collection with date range. See the below example document. I wanna query startTime field using date range.
135
votes
17
answers
99k
views
Is It Possible To Get The ID Before It Was Added?
I know that in Realtime Database I could get the push ID before it was added like this:
DatabaseReference databaseReference= FirebaseDatabase.getInstance().getReference();
String challengeId=...
134
votes
5
answers
155k
views
How to check if a cloud firestore document exists when using realtime updates
This works:
db.collection('users').doc('id').get()
.then((docSnapshot) => {
if (docSnapshot.exists) {
db.collection('users').doc('id')
.onSnapshot((doc) => {
// do ...
128
votes
17
answers
200k
views
Please specify a platform for this target in your Podfile?
I want to config Firebase Firestore. I followed all the steps, but at the last step, I got the error link below I mention.
After Executing this pod install command below error I got
[!] Automatically ...
108
votes
9
answers
53k
views
How to import data from cloud firestore to the local emulator?
I want to be able to run cloud functions locally and debug against a copy from the production data.
Is there a way to copy the data that is online to the local firestore emulator?
101
votes
7
answers
221k
views
How to update a single firebase firestore document
After authenticating i'm trying to lookup a user document at /users/, then i'd like to update the document with data from auth object as well some custom user properties. But I'm getting an error ...
100
votes
29
answers
152k
views
firebase.firestore() is not a function when trying to initialize Cloud Firestore
When I try to initialize Firebase Cloud Firestore, I ran into the following error:
Uncaught TypeError: WEBPACK_IMPORTED_MODULE_0_firebase.firestore is not a function
I installed firebase with npm ...
99
votes
17
answers
62k
views
Firestore: How to get random documents in a collection
It is crucial for my application to be able to select multiple documents at random from a collection in firebase.
Since there is no native function built in to Firebase (that I know of) to achieve a ...
99
votes
14
answers
69k
views
How to run a geo "nearby" query with firestore?
Does the new firestore database from firebase natively support location based geo queries? i.e. Find posts within 10 miles, or find the 50 nearest posts?
I see that there are some existing projects ...
98
votes
11
answers
121k
views
How to delete document from firestore using where clause
var jobskill_ref = db.collection('job_skills').where('job_id','==',post.job_id);
jobskill_ref.delete();
Error thrown
jobskill_ref.delete is not a function
96
votes
7
answers
56k
views
Cloud Firestore: Update fields in nested objects with dynamic key
following the official documentation of firestore :
{
name: "Frank",
favorites: { food: "Pizza", color: "Blue", subject: "recess" },
age: 12
}
// To update favorite color:
db.collection("...
93
votes
11
answers
30k
views
Firestore - batch.add is not a function
The documentation for Firestore batch writes lists only set(), update() and delete() as permitted operations.
Is there no way to add an add() operation to the batch? I need a document to be created ...
90
votes
10
answers
134k
views
Execution failed for task ':app:mergeDexDebug'. Firestore | Flutter
Trying to use Firestore in my project. My project is a brand new one, but having problems running the app on my device without getting an error:
Execution failed for task ':app:mergeDexDebug'.
My app ...
88
votes
7
answers
26k
views
How to export security and index rules from Firestore?
I've set up multiple different indexes on my Firestore development database. Now, I would like to export them into the firestore.indexes.json so that the process of setting up prod environment would ...
88
votes
11
answers
128k
views
Firestore - How to get document id after adding a document to a collection
Is there a way to acquire the document id that was generated after adding a document to a collection?
If I add a document to a collection that represents a "post" in a social media app, I want to ...
85
votes
8
answers
28k
views
How to structure a feed and follow system?
I was using Firebase realtime database for my social network app were you can follow and receive posts of people you follow.
My database :
Users
--USER_ID_1
----name
----email
--USER_ID_2
----name
----...
85
votes
5
answers
45k
views
Firestore slow performance issue on getting data
I'm having slow performance issues with Firestore while retrieving basic data stored in a document compared to the realtime database with 1/10 ratio.
Using Firestore, it takes an average of 3000 ms ...
84
votes
12
answers
82k
views
Firestore: Multiple conditional where clauses
For example I have dynamic filter for my list of books where I can set specific color, authors and categories.
This filter can set multiple colors at once and multiple categories.
Book > Red, ...
84
votes
11
answers
95k
views
Convert date to timestamp for storing into firebase firestore in javascript
I'm currently using Math.floor(Date.now() / 1000) to get the correct timestamp format to add into a document in Firebase, however, the timestamp gets inserted as a number, and not as a timestamp.
I ...
83
votes
7
answers
124k
views
Firebase Cloud Firestore : Invalid collection reference. Collection references must have an odd number of segments
I have the following code and getting an error :
Invalid collection reference. Collection references must have an odd number of segments
And the code :
private void setAdapter() {
...
82
votes
16
answers
88k
views
Export json from Firestore
As we can download json file at Firebase RTDB console, are there any way to export json file of Firestore collection/document data?
One of my main objectives is to compare data before/after updating ...
77
votes
5
answers
92k
views
Firestore update only one field
I have a database. The sequence is: collections - document - hashmaps. For example:
users - the name of the collection
users.uid - the name of the document
Hashmap the document consists of a lot ...
77
votes
3
answers
77k
views
Firestore get all docs and subcollections of root collection
Say I have this kind of structure
A (collection): {
a (doc): {
name:'Tim',
B (collection):{
b (doc): {
color:'blue'
...
76
votes
13
answers
44k
views
Delete a Document with all Subcollections and Nested Subcollections in Firestore
How can you delete a Document with all it's collections and nested subcollections? (inside the functions environment)
In the RTDB you can ref.child('../someNode).setValue(null) and that completes the ...
75
votes
10
answers
180k
views
Firestore Getting documents id from collection
I'm trying to retrieve my documents with id but can't figure it out.
Currently I retrieve my documents like this :
const racesCollection: AngularFirestoreCollection<Races> = this.afs....
74
votes
17
answers
93k
views
Deleting all documents in Firestore collection
I'm looking for a way to clear an entire collection. I saw that there is a batch update option, but that would require me to know all of the document IDs in the collection.
I'm looking for a way to ...
73
votes
1
answer
16k
views
How do I implement a write rate limit in Cloud Firestore security rules?
I have an app that uses the Firebase SDK to directly talk to Cloud Firestore from within the application. My code makes sure to only write data at reasonable intervals. But a malicious user might take ...
72
votes
9
answers
87k
views
Plugin project :firebase_core_web not found
I try to connect Android project to Firebase but I get this error as I added the following to pubsec.yaml:
firebase_auth: ^0.16.0
cloud_firestore: ^0.13.5
when I gradle run and it is not working
...