Supista
Contact Us
documentation
Supista ERP
Parameters
API Operations
Bulk Update

Bulk Update

The bulkUpdateOp function is used to perform mass (batch) updates on multiple rows of a database table in a single operation call.

Instead of sending individual update requests for each row, this function allows you to construct a structured payload that defines:

  • What data needs to be updated
  • Which rows should be updated (conditions)

All updates are executed efficiently in one operation.

This is especially useful in ERP systems and large-scale applications where many records must be modified at once (e.g., updating status, names, prices, etc.).


Usage

const bulkUpdatedData = await bulkUpdateOp("tableName", {
  __d3__updateData: bulkUpdatePayload
});

Payload Structure

The payload must include __d3__updateData, which is an array of update instructions.

{
  __d3__updateData: [
    {
      newData: { ...columnsToUpdate },
      where: { ...conditionToFindRows }
    }
  ]
}

Payload Item Format

Each item inside __d3__updateData must follow this structure:

{
  newData: {
    name: "John Doe",
    status: "Active"
  },
  where: {
    id: row?.id
  }
}

newData

Defines the columns and values to update.

where

Defines the condition used to identify which rows should be updated.


Example Implementation

async function customizeERP(userData, apiOperations) {
 
  const tableName = "tableName";
  const { bulkUpdateOp } = apiOperations;
 
  const bulkUpdatePayload = [];
 
  if (userData && userData.length > 0) {
 
    await Promise.all(
      userData.map(async (row) => {
 
        bulkUpdatePayload.push({
          newData: {
            name: "John Doe",
            status: "Active"
          },
          where: { id: row?.id }
        });
 
      })
    );
 
    const bulkUpdatedData = await bulkUpdateOp("users", {
      __d3__updateData: bulkUpdatePayload
    });
 
    return {
      result: bulkUpdatedData
    };
  }
}

Example Input

[
  {
    "id": 1,
    "name": "Sample",
    "status": "Sample"
  },
  {
    "id": 2,
    "name": "Sample",
    "status": "Sample"
  }
]
Last updated on
Transform Data into Decisions with Supista – Your Intelligent Data Partner
AI Procurement Auditor for Procure-to-Pay

Automate your daily operations. Scale your company with confidence.

Discover the gaps, risks, and inefficiencies in your procure-to-pay cycle. Book a free session with our Automation Experts and uncover how AI can transform your operations end-to-end.