Я создаю таблицу, в которой пользователи вводят такие данные о товаре, как товар, цена и количество. Я думал об использовании кортежей. Но это сложно. Есть ли способ хранения этих динамических c данных и добавления в firestore.
var table_data = document.getElementById('table-body-bill');
var table_length= table_data.rows.length;
for(var i=0;i<table_length;i++){
upload_bill_data=x+'[';
upload_bill_data = upload_bill_data + 'itemName:' + table_data.rows[i].cells.item(0).innerHTML + ',';
upload_bill_data = upload_bill_data + 'price:' + table_data.rows[i].cells.item(1).innerHTML + ',';
upload_bill_data = upload_bill_data + 'quantity:' + table_data.rows[i].cells.item(2).innerHTML;
x++;
}
upload_bill_data += ']';
console.log(upload_bill_data);
}
db.collection('22')
.add({
tt: upload_bill_data
})'`
//Output looks like
upload_bill_data = 1{itemName:"",price:"", quantity:""}
//everything gets stored as a single variable
//But I want the data to be like this.
upload_bill_data = 1 {
itemName:"",
price:"",
quantity:""
}
//It should store it in different elements