Questions tagged [google-cloud-firestore]

0

votes
1

answer
15

Views

How to set and overwrite a whole arraylist in firestore

I have a database setup which looks like this. I want to overwrite the array students with my new array. I tried doing it by the set method but I keep getting an error ' Invalid data. Unsupported type: Models.students' Here's my code. private void update(){ DocumentReference document = db.collectio...
Skeptic94
0

votes
0

answer
4

Views

Get number of documents in a big collection in Cloud Firestore

I know this question was already asked but I'm being specific about my case: I've got a large database (approximately 1 million documents inside the collection users). I wanna get the exact number of documents inside users. I'm trying this: export const count_users = functions.https.onRequest((reque...
Daniel
0

votes
0

answer
3

Views

Cloud firestore rules using exist() does it count as a read?

I am storing a collection of documents of blocked users. I am checking if the request is from a blocked user or not by checking if the email exist within the blocked collection allow read: if exists(/databases/$(database)/documents/blocked/$(request.auth.token.email)) == false; does checking if the...
Mozes ong
1

votes
0

answer
21

Views

Can I update arrays in a batch?

Per the Firestore docs, I can add to an array: regions: firebase.firestore.FieldValue.arrayUnion('greater_virginia') And I can update a field through a batch: batch.update(sfRef, {'population': 1000000}); But can I add to an array through a batch? Something like: batch.update(userDoc, 'arrayField':...
user3653771
0

votes
0

answer
6

Views

Problem with nuxt (SSR) and firestore rules

I use Nuxt (universal mode) with Firestore, I set rules properly but I still get this error: I get Missing or insufficient permissions when I reload the page. When ccessing the page through the router, I don't get any error, the rules re working as it's supposed to. Firestore is called in the async...
Jonathan Pretre
0

votes
0

answer
3

Views

Safari CSS only updates after clicking for text-align: justify

I have a very intriguing bug on Safari for mac (12.0.3), the text doesn't properly justify (screenshot 1) at first render, it only correctly justifies after clicking on it (screenshot 2). I am using React with Material-UI and overriding the style of all my body2 directly in my theme.js file as follo...
Quentin C
0

votes
0

answer
2

Views

Firestore Rules - “exists” function not found when it's inside another function

I have a function in my firestore rules that check if a given document exists: function doesDocExists(docId) { return exists(/databases/$(database)/documents/mycollection/$(docId)) } and in the rules, I write: allow create: if ... && doesDocExists(docId); The problem is that Firestore fails to locat...
Eliya Cohen
0

votes
1

answer
14

Views

NodeJs/React- How to store query results from firestore in variable

function collectres () { var store =''; var docRef = db.collection('cities').doc('SF'); docRef.get() .then(function (doc) { if (doc.exists) { console.log('Document data:', doc.data()); store = doc.data();// when referenced outside, it doesnt hold anything. } else { // doc.data() will be undefined in...
A.b
0

votes
0

answer
6

Views

Complex Data Structure Google Firestore

I was hoping I could get some help on a somewhat difficult problem I am having setting up part of my firestore database. I want to show what the average person is spending on a car and/or house based on location, sex, age, occupation, and income. The trick though is I want to (based on user inputte...
FrankTheTank
1

votes
0

answer
6

Views

Update Firestore objects of one collection if the object of another collection is deleted?

can anyone help me - I believe with the basic thing. I would like to have object of products collection which will keep UID’s of possible objects of components collection. I want to achieve that if I will delete a component object with specific UID, this ID will be deleted in all product objects w...
sbtgE
1

votes
1

answer
194

Views

Cloud Firestore document read cost for subcollections?

How to calculate firestore cost? I know that it count every operation, but if I read one document that contain sub collection how it count? For example, If I read 'A Document' that has 1 'Sub-Collection B' and 'Sub-Collection B' have 5 document. Then how much it could if I only read 'A Document', i...
Hello World
1

votes
1

answer
127

Views

How to paginate Firestore dataset by individual page?

I want to paginate my forum posts stored in Firebase by pages of 20 items, like so: User accesses foo.com/1 --> most recent 20 posts are loaded User accesses foo.com/2 --> posts 21-40 are loaded and so on. Now I am aware I can work with query cursors (as mentioned here), which works perfectly fine f...
Pascal
1

votes
1

answer
305

Views

accessing doc.id in .onWrite firebase cloud function

I'm triggering a cloud function with onWrite. Within the onWrite function, I want to do something with the ref ID of the document that was written. How can I grab this? My current code looks something like this, but I don't know how to fill eventID. exports.syncEvents = functions.firestore .document...
T_R_U_T_H
1

votes
1

answer
1.1k

Views

Angular Firestore Get Single Document With Query

I'm using Google Firestore. There is a collection called Universities, where each document represents a university. How do I find a university by its name and update its view_count by +1? [Collection: Universities]: [Document: 0JsaLtcfdDaEtHLMlMrh]:{ name: The University of Sydney, view_count: 1 };...
Efan Du
1

votes
1

answer
163

Views

Detected an object of type “Timestamp” that doesn't match the expected instance

I'm wondering why is the Timestamp object is not working as I expect? It works in test environment (I use Mocha), but throws error when it has been deployed. index.ts import { Timestamp, QuerySnapshot } from '@google-cloud/firestore'; .... async someFunction() { let col = firestore.collection('myco...
Yosi Pramajaya
1

votes
3

answer
32

Views

Typescript array of promises resolving properly in one case but not in another

I have a function that maps each element of an array (email addresses in this case), yielding an array of promises that should resolve to document ids automatically generated by Firebase (i.e. hAvJ3qPq821tq1q2rrEv, 0tjeKB1aW8jsOAse5fcP). async function addMultipleParticipants(participant_emails: Arr...
haudarren
0

votes
0

answer
4

Views

How to add indexes or denormalize Firestore database for scheduler app

I am creating a calendar app like Google calendar with Firebase. A group of user have multiple calendar and, a calendar has many events. Each event has a period represented as begin date and end date. Some events are one day long and, some are longer than a month. I want to query events whose period...
Tsubasa
0

votes
1

answer
29

Views

Filter an Observable array to return one result

I'm doing a web application in Angular 6 and angularfire2. In my service, I have an Observable array and I want to filter it to return just one result. Inside of all documents, there is a map called moderatorAssigned with an id property, this id is the uid of the user in firebase. I have companies,...
RRGT19
0

votes
0

answer
7

Views

How to add Activity indicator to end of UICollectionView

Hi I have been trying to add an Activity Indicator, or a Loading spinner, to the bottom of my collection view. I have searched online on how to do so but there is not a clear way to do so. I do not want to use a cell for the indicator itself because my cells a pretty big. (2 cells take up the whole...
Mario Lopez
0

votes
1

answer
16

Views

Firestore: com.google.cloud.firestore.CollectionReference.where() not working

I am trying to check if a user exists in a nested field, but I keep getting this error. No signature of method: com.google.cloud.firestore.CollectionReference.where() is applicable for argument types: (com.google.cloud.firestore.AutoValue_FieldPath, java.lang.String, java.lang.String) values: [resp...
anushka
0

votes
1

answer
12

Views

How to check if array contains two specific strings in Firestore?

I'm trying to make a chat app that can have chatrooms with max two users. I got a collection chatrooms and chatroom-documents with an array field members that contains two user id's. Know before I can create a new chatroom I want to check if two specific users already got a chatroom together, so I...
Constantin Beer
1

votes
0

answer
15

Views

Comparing document timestamps in Firestore rules

I'm running into a weird problem while writing and testing my Firestore rules. What I'm trying to achieve is comparing the timestamp of an existing document in the database to a timestamp that was sent for the document that is being created. I'm doing this to make sure there's some time between the...
joranderaaff
0

votes
3

answer
33

Views

Java, get Keys from Map that has data from FireStore

I'm getting data from FireStore into a Map, my data in Firestore looks like this: (Auto-Document ID) title='title1' body='body1' (Auto-Document ID) title='title2' body='body2' As I load them in a Map, it'll look like this: loadNoteCallBack: {rsmw3EkfIjUQxrzRiyy7={body=body2, title=title2}, sTEfY...
Máté Antal
-1

votes
1

answer
28

Views

Why can I use an Observable without subscribe?

My problem is this example https://github.com/AngularFirebase/144-firestore-group-chat from Jeff Delaney. I'm trying to understand why it is possible to use an observable without subscribe(). For example the auth.service.ts from the Github repo: import { Injectable } from '@angular/core'; import {...
Constantin Beer
0

votes
0

answer
7

Views

Convert firebase.firestore.timestamp to date before patchValue of data in a reactive form

I am trying to load a field which is stored as a timestamp in firestore and populate a “mat-datepicker“ form control which uses Date formats. Is there any way of modifying the format of the 'dob' data before it reaches the Angular Material datepicker control? The date picker doesn't like the...
Research Stuff
1

votes
0

answer
12

Views

Cloud Firebase - Disable Analytics service

I wrote an App, that is used only by me and one family member. I am using cloud firestore. I got an notification that I have to change my data sharing settings. So I disabled the google analytics collection. I won't upload the app on Google play. Just install the apk on our two devices. Do I still h...
ne el
0

votes
0

answer
2

Views

Task gets repeated in firestore when querying documents

I have a problem in querying documents in firestore. It evaluates the task 2 times which saves the document id in the ArrayList in duplicates. public void setMessageCount(final TextView txtComments) { userColelction.get().addOnCompleteListener(new OnCompleteListener() { @Override public void onComp...
John Ranel Tuble
1

votes
0

answer
9

Views

Firebase stored data with ${res.user.uid} instead of userid

Firebase stored data with ${res.user.uid} instead of userid .Please advise solution how to store user with userid try{ const res= await this.afAuth.auth.createUserWithEmailAndPassword(username,password) this.afstore.doc('users/${res.user.uid}').set({ username }) this.user.setUser({ username, uid:res...
1

votes
0

answer
9

Views

How to structure Firestore data to support large a many to many relationship?

My UI needs to support the following functionality: Users can follow other users A user can like a post A user needs to see on ONE page all posts that any of the users they follow (and/or themselves) have liked, including who, how many, etc Users will be accessing this data and liking frequently so...
Caleb Friden
1

votes
1

answer
251

Views

React Native - Cannot get item in array, or show items from array in list

I have been trying to debug this for hours now but to no avail. I wrote this script that basically when the component loads fetch information from my Firestore database. I then log one item from the array to the console, resulting in undefined. I don't understand why it can show me the full array bu...
Anthony Sette
1

votes
1

answer
508

Views

How to get time ago from a firestore timestamp (firebase)? [closed]

I've been trying to get the 'time ago' from a date I have stored in a firestore database. I've tried two packages that are supposed to do that but I can't get it to work with the firestore timestamp and honestly I can't believe it is as hard as it's been to get this. Whats the easiest way to get the...
Gabriel Martins
1

votes
1

answer
973

Views

How to query nested objects in firestore

I want to store data in following format: { 'chatName': 'Football', 'chatMembers': [ { 'userId': 'nSWnbKwL6GW9fqIQKREZENTdVyq2', 'name': 'Niklas' }, { 'userId': 'V3QONGrVegQBnnINYHzXtnG1kXu1', 'name': 'Timo' }, ] } My goal is to get all chats, where the signed in user with a userId is in the chatMe...
Niklas Raab
0

votes
0

answer
5

Views

Flutter issue: type 'Timestamp' is not a subtype of type 'DateTime'

I'm looking for some help for an app my team and I are working on. We are facing the following problem for weeks : flutter type 'Timestamp' is not a subtype of type 'DateTime' We want to get these user data from Cloud Firestore: birth [DateTime] gender [String] license [DateTime] name [String] size...
Barracud Apps
1

votes
2

answer
876

Views

How to write to a cloud storage bucket with a firebase cloud function triggered from firestore?

To make sure this is as clean and isolated as possible, I created a new test project with nothing in it other than these steps. I then enabled cloud firestore in the console. I created a new collection called 'blarg' (great name, eh!). I added a document to it, and used the auto-id, then added a fi...
xrd
1

votes
1

answer
506

Views

Creating secure REST-like API with firestore

I'd like to store one-to-many relationship in firebase firestore. Let's say I have an author, and there are books belonging to this author. I could store it in a nested relationship: author/ authorId1 : { books: [{...}, {...}] } But I also need a way to list all books, preferably without iterating t...
fodma1
1

votes
2

answer
2.9k

Views

Unable to resolve Firestore dependency

This is my app gradle file apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion '25.0.3' defaultConfig { applicationId 'com.fitness.perspactive' minSdkVersion 17 targetSdkVersion 26 versionCode 1 versionName '1.0' testInstrumentationRunner 'android.support.test.ru...
vardhanv35
1

votes
1

answer
1.2k

Views

How to add data like this in Firebase's Cloud Firestore?

In JavaScript, I wrote something like this but it returns error > 'Document references must have an even number of segments'. I need to use 'set' and not 'add' for my case. const ref= db.collection('product'); ref.doc('111').doc('category').set({ clothes: true }); In Firebase's Realtime Database, I...
the newbie coder
1

votes
1

answer
669

Views

Lazy loading in Cloud Firestore

So for example I have a collection of tasks inside a document my-task inside a collection of comments tasks/my-task/comments Is there a way to download the document along with the sub collection it holds Adding something to the following to make some eager load of the sub collection? firebaseDb.coll...
Gal Bracha
1

votes
1

answer
462

Views

How to type-check optional properties in Firestore

I can't figure out how to do optional properties in Firestore. It doesn't seem to be covered in the docs and the following fails for me. service cloud.firestore { match /databases/{database}/documents { function maybeString(val) { return val == null || val is string } match /myCollection/{document}...
rhythnic
1

votes
1

answer
649

Views

Can I query a nested document value in firestore?

I'm looking to do a search on the following data in firestore: Collection->Document->{date{month:10,year:2017}} var ref = db.collection(collection).doc(document) ref.where('date.month', '==', 10).get().then(doc=>{ if (!doc.exists) { console.log('No such document!'); } else { console.log('Document da...
Greg

View additional questions