Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const onItemCreate = functions.database
- .ref('phones/{itemId}')
- .onCreate((snapshot, context) => {
- const { stockId } = snapshot.val()
- const stockRef = ad.database().ref(`stock/${stockId}`)
- return stockRef.transaction(stock => {
- if (stock) {
- stock.quantity++
- }
- return stock
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement