mirror of
https://github.com/System-End/site.git
synced 2026-04-19 22:05:11 +00:00
Do query thing
This commit is contained in:
parent
0c45788fa6
commit
6b802206ef
1 changed files with 7 additions and 10 deletions
|
|
@ -18,16 +18,13 @@ export const shopParts = async () => {
|
|||
let stock = fields["Stock"]
|
||||
|
||||
if (stock) {
|
||||
await ordersTable.read({
|
||||
filterByFormula: `AND(
|
||||
{Item} = "${record["Name"]}",
|
||||
OR(
|
||||
{Status} = "Fulfilled",
|
||||
{Status} = "Awaiting Fulfillment"
|
||||
)
|
||||
)`
|
||||
})
|
||||
stock -= records.length;
|
||||
const records = await ordersTable.read();
|
||||
const targetRecordId = record.id;
|
||||
const matchingRecords = records.filter(recordToFilter =>
|
||||
recordToFilter.id === targetRecordId &&
|
||||
(recordToFilter.fields["Status"] === "Fulfilled" || recordToFilter.fields["Status"] === "Awaiting Fulfillment")
|
||||
);
|
||||
stock -= matchingRecords.length;
|
||||
}
|
||||
return { id: record.id, ...record.fields, "Stock": stock ?? null }
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue