Skip to main content
100%

Banking

✓ Published0🌍 Public
Aandresmijares
Last edited May 5, 2019
Created on May 5, 2019

This example shows a Firebase-backed banking transaction that processes a coin purchase in real time. It demonstrates how a Cloud Firestore transaction atomically checks a user’s coin balance, verifies item availability, deducts the total cost, updates the item quantity, and records the purchase in a separate collection. The code uses the `firebase-admin` SDK, `db.runTransaction`, and `transaction.get`, `transaction.update`, and `transaction.set` to lock and modify documents. It also relies on `functions.https.onCall` to expose the purchase operation as a callable cloud function, with error handling for insufficient funds or stock.

AI-generated description

Similar vizzes