get Inventory History
unknown
javascript
a month ago
1.1 kB
3
Indexable
async function getInventoryHistory({ warehouse_id, lastEvaluatedKey, limit = 10 }) { try { const queryParams = { TableName: process.env.INVENTORY_UPDATE_EVENT_TABLE, KeyConditionExpression: "warehouse_id = :warehouse_id", ExpressionAttributeValues: { ":warehouse_id": { S: warehouse_id } }, Limit: limit, ScanIndexForward: false }; if (lastEvaluatedKey) { queryParams.ExclusiveStartKey = await JSON.parse(decodeURIComponent(lastEvaluatedKey)); } const result = await dynamodb2.send(new import_client_dynamodb2.QueryCommand(queryParams)); const response = { items: result.Items || [], lastEvaluatedKey: result.LastEvaluatedKey || null }; return { statusCode: 200, body: JSON.stringify(response), headers: headers2 }; } catch (error) { console.error("Error querying inventory history:", error); return { statusCode: 500, body: JSON.stringify({ message: "Could not fetch inventory history" + error }), headers: headers2 }; } }
Editor is loading...
Leave a Comment