Supista
Contact Us
documentation
Supista ERP
Parameters
API Operations
Remove Operation

Remove Operation

The removeOp function is used to delete one or more records from a PostgreSQL table.


Usage

const deletedData = await removeOp(tableName, payload);

Parameters

tableName (Required)

The name of the PostgreSQL table from which records will be deleted.

payload (Required)

A modified userData payload including the IDs of records to delete.

If deleting from a related table, the payload must also include:

  • __d3__parentId
  • __d3__relationId

Payload Structure

{
  __d3__id: [4]
}

__d3__id can be a single ID or an array of IDs to delete.


Return Value

Returns the result of Sequelize dataModel.delete() indicating the number of records deleted.

Sample Output

{
  deletedObjNo: 1
}

Example Implementation

async function customizeERP(userData, apiOperations) {
 
  const tableName = "table_name";
  const { removeOp } = apiOperations;
 
  return new Promise(async (resolve, reject) => {
 
    const payload = {
      __d3__id: userData?.__d3__id
    };
 
    const deletedData = await removeOp(tableName, payload);
 
    if (deletedData?.deletedObjNo) {
      resolve({ result: deletedData });
    } else {
      resolve({
        result: {},
        popupMsg: {
          type: "error",
          message: "Could Not create data! Please try again later"
        }
      });
    }
 
  });
}

Example Input

{
  "__d3__id": [4]
}

Example Output

{
  "response": {
    "__d3__result": {
      "result": {
        "deletedObjNo": 1
      }
    },
    "__d3__error": false,
    "printConsole": []
  }
}
Last updated on
Transform Data into Decisions with Supista – Your Intelligent Data Partner
AI-Powered Operational Intelligence for Growing Businesses

Automate your operations. Orchestrate your workflows. Scale with confidence.

Book a free strategy session with our Automation Experts and discover how Supista’s AI-Composable ERP can transform your operations into a scalable and intelligent system.