Is the document snapshot from Expressive Querying auto updated in Firestore?

Expressive Querying is a big differences with Firestore and Realtime Database. If I use addSnapshotListener to a document. I know the snapshot of document will be auto updated at any changing from cloud.But how about the snapshot from Expressive Querying? I didn't find the detail from the Firestore website.For example, first for the Document.If I have used get function to query a document posts/{postId} and get the snapshot of this document. But I didn't addSnapshotListener for this document. So will the snapshot be auto updated on the backgrou...Read more

Query Google Firestore database by custom object fields

I've got the following Google Firestore database structure:Is there a way to query by a range of each - latitude and longitude? For example I want to get all users which have location.lat and location.lng in the range of: 51.400 to 52.000 and -0.100 to -0.300. Can anyone please help me figure out the query needed to do that?I hope this question makes any sense. Any help appreciated.Edit: I am not using a 'Geographical point' data type. I am using a custom object with 2 float numbers and want to do a simple number compare. The thing is that I do...Read more

javascript - How do I make toLowerCase() and toUpperCase() consistent across browsers

Are there JavaScript polyfill implementations of String.toLowerCase() and String.toUpperCase(), or other methods in JavaScript that can work with Unicode characters and are consistent across browsers?Background infoPerforming the following will give difference results in browsers, or even between browser versions (E.g FireFox 54 vs 55): document.write(String.fromCodePoint(223).normalize("NFKC").toLowerCase().toUpperCase().toLowerCase())In Firefox 55 it gives you ss, in Firefox 54 it gives you ß.Generally this is fine, and mechanisms such as Lo...Read more

Firestore create security rule not behaving as expected

I created a jobs collection with a job document having a job id (XAXhAJh71hHbe1fY7blZ) and added the following security rules:match /{document=**} { allow read, write: if false;}match /jobs/{jobId} { allow create: if request.auth.uid != null;}According to the docs create "Applies to writes to nonexistent documents". Namely if the document exists this operation should be rejected.However the Firestore simulator allows to create over existing document id.Namely executing create on /jobs/XAXhAJh71hHbe1fY7blZ is being allowed by the emulato...Read more

Google Cloud Firestore console reading of all documents and charges

I am new to Firestore so I have a Profiles and Users collections. In the Cloud Firestore Console when I click on Database > Firestore > Data tab > Profiles or > Users the console is reading ALL the documents in each collection. These reads are counted in the Usage tab. So my question is if I have lets say 500K documents in the Profiles collection and clicked on Data I will be charged for reading 500K docs just to view the first 25 docs only. Just clicking on Data tab the console reads all the docs of the first Collection. I tried using the filt...Read more

How do I handle FieldValue.delete() in Firestore security rules?

I have a document where each invited user has a field (their request.auth.uid), with a number value representing their access level.I want users to be able to delete their user field from the document, but not be able to increase the level of their field. The code to remove their own user field is simply:documentReference.update(myUserId, FieldValue.delete());I can delete the field fine, but I can't figure out how to write a rule to allow for this (and not other updates to the field) in Firestore Security. I've tried rules like: allow upda...Read more

datetimeoffset - Cloud Firestore: Storing and querying for today's date over multiple UTC offsets?

I'm writing a web app using Firestore that needs to be able to show "Today's Popular Posts" and I'm having trouble getting the queries right when considering users in different timezones.The dates are stored in the DB as UTC 0, then adjusted to the current user's UTC offset in the client via Moment.js. This works correctly.When adding a new post I use firebase.firestore.FieldValue.serverTimestamp() to store the current server timestamp in a field called timestamp, like so:const collectionRef = db.collection('posts');collectionRef.add({ name: "...Read more

angularfire2 - Firestore: set fields of implicitly created documents

I'm building a group chat system using Google Firestore. For each group, I'm using a custom Firestore document ID to identify the chat room where messages belong. Every time a user send a message to a room, this snippet works even if the document with that ID does not exists as documents are created implicitly:this._firestore .collection('rooms') .doc('group' + group.id) .collection('messages') .add({ uid: message.from.id, content: message.content, date: firebase.firestore.FieldValue....Read more

AngularFire2 / firestore valueChanges() returning null when there is data

I'm trying to get a document out of a firestore collection on load of a angularfire2 application. When loading the application in incognito mode the function returns null on first load, but after a refresh it returns the data I'm expecting. public GetConfig(): Observable<Config> {return this.documentDB .collection("Configs") .valueChanges() .do(c => { this.SetCurrentVersion((c[0] as Config).currentversion); }) .map(c => c[0] as Config);}Has anyone else run into issues like this? I have verified that the Configs collection ha...Read more

google cloud functions - How can we get Firestore to trigger an event when a document's Date/Time field matches current time?

Suppose I have a Firestore document and has a Date/Time Field called "AlarmTime" which holds some future Date/Time value.Q1: Is there a way to tell Firestore to Trigger an event when any document's "AlarmTime" matches Current Time, so we can respond to that trigger event in a Cloud function?Q2: If that is not possible, what would be the most efficient way in a Cloud Function to find any document's that it's "AlarmTime" field has reached the current time? I would find it inefficient to Poll the database continuously. Thank you in advance!..Ben...Read more

Module '@google-cloud/firestore' is not listed as dependency in package.json

I am using TypeScript for writing my Firebase Cloud Functions. In my code I need to refer firestore data types like CollectionReference, QuerySnapshot etc. For example:export const Employee: CollectionReference = admin.firestore().collection('Master/Admin/Employees');orasync function convertToCsv(snapshot: QueryDocumentSnapshot[])To use these types in my code, I am using the following lines on the top of the file (.ts):import { QueryDocumentSnapshot, Timestamp, Query, CollectionReference } from '@google-cloud/firestore';This code works fine whe...Read more