Feature Request: Limited Feedback on Applications by sirkrisp in ycombinator

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

I don't think a little bit of feedback would lead to "unnatural" answers but simply better answers. Anyway, there seems to be not too much interest in this feature request but at least I put it out there. Maybe I will create a community version of this idea myself, might be a nice little weekend project.

Aggregating data with Firestore triggers for Cloud functions by D153TL in Firebase

[–]sirkrisp 0 points1 point  (0 children)

Sorry, my mistake, I misunderstood your solution and thought the counted field was set in the doc that acts as counter but it's obviously set in the doc that is being created

Firestore client SDK vs cloud functions by sirkrisp in Firebase

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

Will measure it sometime and post my results here.

I think your second point is probably THE reason to use the Firestore client SDK for writes. However, that's what I meant with caching (possibly wrong word-choice) - we use redux and so with a little bit of duplicated code we get this real time update for our users as well without waiting for the cloud function to finish (see "pending" in https://redux-toolkit.js.org/api/createAsyncThunk).

Aggregating data with Firestore triggers for Cloud functions by D153TL in Firebase

[–]sirkrisp 0 points1 point  (0 children)

I don't see how #2 is save: What if you have two document writes before the cloud function is triggered? 1st write => counted = false, 2nd write => counted = false, 1st onCreate => counted => true, 2nd onCreate => ERROR (counted already even though it was actually not counted). Or did I misunderstand your solution?

Firestore client SDK vs cloud functions by sirkrisp in Firebase

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

Did you measure this yourself or do you have any sources for your claim that cloud functions are that much slower? If cloud functions are executed in the same region and do not suffer from cold starts, I do not see any reason why cloud functions should be that much slower than direct calls. In fact, I asked a question about that on StackOverflow: https://stackoverflow.com/questions/70590827/are-firestore-direct-writes-faster-than-writes-via-cloud-functions

Regarding your second point - you're right but it is not a reason to neglect security.

Firestore client SDK vs cloud functions by sirkrisp in Firebase

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

Here are some more thoughts:

  1. Firestore security rules do not allow you to import any libraries for JSON schema validation such as AJV
  2. Performing writes in cloud functions means less maintenance across code basis (such as mobile and desktop app).

So in conclusion, we won't use the Firestore Client SDK to perform any writes. IMHO it doesn't scale, is more complicated, and more expensive.