I am trying to create a shopping cart and save it to firebase using redux-saga. my carts like this
{
products: [
{
product_id: 'id1',
product_name: 'product 1',
product_quantity: 2,
product_price: 50,
},
{
product_id: 'id2',
product_name: 'product 2',
product_quantity: 2,
product_price: 2,
}
],
userID: 'user1'
}
firebase.js
export const addToCartFirebase = (cart) => {
firestore.send(cart); //fake
};
cart.saga.js
export function* handleAddToCart(action) {
const { cart } = action;
const newCart = yield call(addToCartFirebase, cart);
}
I am very new to firebase. How I make cloud functions receive a cart and if it exists in the database it just increases the quantity of product, if the cart does not exist in the database it creates a new one