Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. export const onItemCreate = functions.database
  2. .ref('phones/{itemId}')
  3. .onCreate((snapshot, context) => {
  4. const { stockId } = snapshot.val()
  5. const stockRef = ad.database().ref(`stock/${stockId}`)
  6. return stockRef.transaction(stock => {
  7. if (stock) {
  8. stock.quantity++
  9. }
  10. return stock
  11. })
  12. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement