I have a collection of items called 'order' that I want to store in my cloud firestore database.
order: [
{
product: 'Coffee',
productivity: '20',
quantity: '8',
},
{
product: 'Snacks',
productivity: '10',
quantity: '5',
},
],
Previously, my application only allowed adding a single product at a time, and the function worked well (based on pinia store).
async addOrder(clientId, newProduct, newProductivity, newQuantity) {
const storeAuthentication = useStoreAuth()
await addDoc(collection(db, 'users', storeAuthentication.user.id, 'clients', clientId, 'orders'), {
product: newProduct,
productivity: newProductivity,
quantity: newQuantity,
productionTime: newQuantity / newProductivity
})
},
Now, I need to add multiple products simultaneously. Currently, I am storing the data locally. Essentially, it functions as a simple shopping cart, but I haven't found a suitable solution that fits my requirements.
Below is the code where I invoke the addOrder function in my component.
const addOrders = () => {
storeOrders.addOrder(newOrderName.value, newOrderProduct.value, newOrderProductivity.value, newOrderQuantity.value)
newOrderProduct.value
newOrderProductivity.value = ''
newOrderQuantity.value = ''
}