fix: prevent UPSERT from squashing historical data by generating a composite fallback order ID
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m2s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m2s
This commit is contained in:
@@ -174,7 +174,9 @@ app.post('/api/data', authenticateAPIKey, async (req, res) => {
|
|||||||
|
|
||||||
for (const item of payload) {
|
for (const item of payload) {
|
||||||
// Handle potential missing fields gracefully
|
// Handle potential missing fields gracefully
|
||||||
const orderId = item.id || item.ID_Pedido || (item.json && item.json.body && item.json.body.id) || '';
|
// If there is no explicit ID, create a composite ID using Name + Date + Value to prevent squashing historical data
|
||||||
|
const fallbackId = `${item.Nome_Cliente}_${item.Data_Pedido}_${item.Valor_Pedido}`;
|
||||||
|
const orderId = item.id || item.ID_Pedido || (item.json && item.json.body && item.json.body.id) || fallbackId;
|
||||||
|
|
||||||
const values = [
|
const values = [
|
||||||
item.Nome_Cliente || 'Unknown',
|
item.Nome_Cliente || 'Unknown',
|
||||||
|
|||||||
Reference in New Issue
Block a user