Firebase cloud function idempotency in docs

亡梦爱人 提交于 2021-02-10 20:19:52

问题


I'm following the docs for Firestore here on Aggregation Queries.

I couldn't help but notice that the cloud function solution wouldn't exactly work since it's not idempotent: numRatings is incremented and avgRating recomputed each time.

Though this example could be made idempotent if there was also a separate document being stored for each new rating: you'd add a check if the user has already submitted a rating for the restaurant.

Is there something I'm missing that makes this example idempotent? Or is the point of the example just to show that this could be done in a cloud function?


回答1:


Making a function idempotent requires a lot of extra lines of code, which would make the example much harder to understand. You should expect that sample code not to be idempotent, unless it's trying to demonstrate idempotence.

If you have feedback for the authors of the documentation, you are free to give that with the "SEND FEEDBACK" button at the top of each page.



来源:https://stackoverflow.com/questions/54619473/firebase-cloud-function-idempotency-in-docs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!