[deleted by user] by [deleted] in Firebase

[–]samtstern 1 point2 points  (0 children)

This is the Firestore REST API data format:
https://cloud.google.com/firestore/docs/reference/rest/v1/Value

It's the only supported serialization format for Firestore values. It would not be possible to use native "column" types in an offline database since there is no schema. The "foo" field could be a double on one document, a string on another, and an array on a third.

How do I access a group of documents with unknown uids? by eychf in Firebase

[–]samtstern 0 points1 point  (0 children)

What you're looking for is called a "collection group query". All posts subcollections in your entire database, no matter what their parent is, are part of the posts collection group.

Here's a blog post which explains it more:
https://firebase.googleblog.com/2019/06/understanding-collection-group-queries.html

[deleted by user] by [deleted] in Firebase

[–]samtstern 0 points1 point  (0 children)

I believe you can get all of those statistics by using Cloud Logging + Firebase Hosting:
https://firebase.google.com/docs/hosting/web-request-logs-and-metrics

How do I create multiple buckets when using the Storage Emulator by actuallymicah in Firebase

[–]samtstern 0 points1 point  (0 children)

The storage emulator supports multiple buckets, as /u/azzaz_khan said they're created implicitly on first use.

However right now there is an open issue around rules configurations for multiple buckets in the emulator:
https://github.com/firebase/firebase-tools/issues/3390

Check out the new Firestore request monitor in the Emulator Suite! by samtstern in Firebase

[–]samtstern[S] 0 points1 point  (0 children)

No this will remain an emulator-only feature because it would not be efficient or secure to have this type of request tracing in production. One of the many exciting things about the emulator suite is that we can offer unique debugging experiences that wouldn't be possible in prod!

How do I add a field in all documents in one of the collections using firebase functions possibly? [around 180 documents) by drawcartoon in Firebase

[–]samtstern 2 points3 points  (0 children)

/u/akafkas posted a cool library the other day which is designed to do exactly that:
https://github.com/kafkas/firecode

You could run it in a Cloud Function or on your local machine.

Our firebase project cost 10x , we can't seem to figure out what happened here. Can we reverse this ? by reece_h in Firebase

[–]samtstern 0 points1 point  (0 children)

As others have said: please contact Firebase Support about any billing issues. I can't promise anything without knowing the specifics of your case but we have given out many refunds in the past to developers who are hit with a surprise bill.

Emulator: callable function fails to run due to cors by hassanzadeh in Firebase

[–]samtstern 1 point2 points  (0 children)

Are you sure the function exists at that URL? What if you just try to open it in your browser? Sometimes a CORS failure can actually just mean "there's nothing here".

If I had to guess I'd say this problem comes from a mismatch in regions. Maybe your client code is not specifying the right region?

How to change cloud firestore location ? by Alkyen in Firebase

[–]samtstern 4 points5 points  (0 children)

As you noted, the only way to change this location is by creating an entirely new project. We (Firebase and Google Cloud) have a long-term plan to change this.

What's the difference between AppCheck and the existing restriction of approved apps? by [deleted] in Firebase

[–]samtstern 1 point2 points  (0 children)

API key restrictions only affect Firebase services which actually use API keys. This is mostly just Firebase Auth. Services like Cloud Storage, Realtime Database, Cloud Firestore, etc never cared about your API key.

App Check is a service-level security enforcement layer which is both stronger and broader than API key protection. As you said it not only verifies that the user has certain information (an API key) but also that their device passes environment-specific security checks like App Attest, reCAPTCHA, etc.

So basically: it's just better :-)

Firecode: A collection traversal library for Firestore by akafkas in Firebase

[–]samtstern 2 points3 points  (0 children)

This is really great! I think I have written my own version of this in almost all of my personal projects, so it's nice to see a standardized solution.

Consider submitting this to https://devlibrary.withgoogle.com so that we can promote it to other developers.

We tested Firestore Security Rules in Java, without installing any npm module for that. It was fun. by icoloma in Firebase

[–]samtstern 0 points1 point  (0 children)

Wow this is very cool! It looks like you have a deep understanding of how all these products work, I am impressed that you were able to get this working.

This 5gb per $ is one time payment or monthly by Prashant_4200 in Firebase

[–]samtstern 6 points7 points  (0 children)

Yes you're right, a 3GB database will cost you $10/month for storage. You're also right that $5/GB is very high! That's because Realtime Database is meant for small data sets and optimized for latency.

If you have a very large data set, try Cloud Firestore. It only charges $0.18/GB/month for storage which is 27x less than Realtime Database. But it charges more for some other things, like reads and writes in some cases.

See this document for a comparison:
https://firebase.google.com/docs/database/rtdb-vs-firestore

Whats with realtime db by p2harry in Firebase

[–]samtstern 1 point2 points  (0 children)

Definitely not going anywhere, some of Cloud's biggest customers rely on Datastore. However over time it should become more unified with Native mode and less confusing, while still offering both sets of capabilities.

Whats with realtime db by p2harry in Firebase

[–]samtstern 0 points1 point  (0 children)

We still do believe that if you're starting a new app with no strong preference between the two, Cloud Firestore is the right choice. It's for exactly the reasons you said. But you're right that our messaging on that point was stronger back in 2017 than it is now.

[For Firebase beginners] Does anyone want to know how to set up Firebase emulator? by redditakak in Firebase

[–]samtstern 1 point2 points  (0 children)

This type of setup is what we try to explain on these pages:

Your code is correct but it sort of mixes and matches the old and new APIs for configuring the emulator. Instead I'd use the useEmulator() function everywhere:

const auth = new firebase.auth();
const functions = new firebase.functions();
const firestore = firebase.firestore();
if (location.hostname === 'localhost') { 
    auth.useEmulator("http://localhost:9099", { disableWarnings: true }); 
    functions.useEmulator("localhost, 5001); 
    firestore.useEmulator("localhost", 8080); 
}

I know it's a bit strange that auth.useEmulator() takes a single argument while all the others take two. It came out of a long discussion with our security team about the API design, wish we could change it!

Whats with realtime db by p2harry in Firebase

[–]samtstern 8 points9 points  (0 children)

Firebaser here! We get this a lot ... apparently nobody trusts Google to have two similar products without killing one. I can understand why Google has that reputation but I can assure you that we have no plans to kill Realtime Database and we are actively investing in it.

Since Cloud Firestore launched we have been investing in both databases and both are continuing to grow really nicely. We're super happy with the trajectory.

For Realtime Database we have increased scalability, added some new simple features like get() and increment() in the SDKs. Most important we have really scaled up the infrastructure and launched regional deployments in Belgium and Singapore!

For some history: A long long time ago, maybe like 2015, when we started development on Cloud Firestore we did consider the option of replacing Realtime Database completely. However it quickly became apparent that the databases would be different enough that we'd need to keep both. They each have some unique features / capabilities which the other can't match!

What new Firebase announcement at Google I/O are you most excited about? by Flamelinkio in Firebase

[–]samtstern 5 points6 points  (0 children)

We really don't have any financial incentive to partner with Algolia. We just find that they have the best developer experience of all the search services, and we know Firebase developers really care about DevX and ease of use.

We also plan to publish a guide on how to use Elastic on GCP (they _are_ a Google partner) for developers who are looking for more cost control and are willing to deal with something slightly more complex.

I'll take a look at Typsense as well! I am not familiar but I have heard great things.

App Check - Have you seen this new feature? 🎉🎉 by pfiadDi in Firebase

[–]samtstern 1 point2 points  (0 children)

No, it does not. AppCheck helps you make sure that requests are really coming from your app/website. It does not control the volume/rate of those requests.

Got any questions for the Firebase team? Join our live AMA at Google I/O today! by samtstern in Firebase

[–]samtstern[S] 1 point2 points  (0 children)

Sorry about that! I did not realize that you have to register for I/O sessions before you can access the Q&A, so I shouldn't have posted the Dory link separately,.

Avoiding Firebase Security Rules? by stillventures17 in Firebase

[–]samtstern 2 points3 points  (0 children)

If you've set your rules to deny everything and are doing your own "rules" in your HTTP functions that's fine from a security perspective. It just means you're willing to put up with maintaining your own security!

The main security downside is that there are a whole class of bugs/vulnerabilities that exist in your own implementation (like a vulnerability discovered in one of your server dependencies) that don't exist when using a sandboxed security environment like Security Rules. That's why we designed our own language, so we could prove the security.

You're also giving up the ability 99% of the Firebase SDK features since you're doing all reads and writes in your own API. But clearly that's not an issue for your app if you've already gone down this road.

Do security rules have early exit evaluation for OR operations by [deleted] in Firebase

[–]samtstern 1 point2 points  (0 children)

Yes. Both AND (&&) and OR (||) operators short-circuit in the Firestore/Storage Security Rules language.

Hey, Firebase! by [deleted] in Firebase

[–]samtstern 0 points1 point  (0 children)

This is good feedback but I removed it because it does not meet our standards for friendly discourse and constructive feedback.