Supista
Contact Us
documentation
Supista ERP
Parameters
Relational API Operations

Relational API Operations

These advanced helper functions are designed to handle CRUD operations on related tables—those nested under a parent component in Supista ERP. Each function requires both the parent record ID (__d3__parentID) and the relation ID (__d3__relationID), which are typically available in the userData object.

Relational API Operations List


createOpWithRelation

Usage:

const createdData = await createOpWithRelation(
  tableName,
  payload,
  __d3__parentID,
  __d3__relationID
);

tableName: The name of the table must be the main table of the component.
payload: Contains the modified userData for the Create API request.
__d3__parentID: use the __d3__parentID from the userData.
__d3__relationID: Relation ID identifying the child relationship. use the __d3__relationID from the userData.

Return Value:
Returns the result of Sequelize dataModel.create() — the newly created record.

Sample createdData Output:

{
  id: 1,
  columnName1: 'columnValue1',
  columnName2: 'columnValue2',
  columnName3: 'columnValue3',
}

readOpWithRelation

Usage:

const rowsData = await readOpWithRelation(
  tableName,
  payload,
  __d3__parentID,
  __d3__relationID
);

tableName: The name of the table must be the main table of the component.
payload: Contains the modified userData for the Create API request.
__d3__parentID: use the __d3__parentID from the userData.
__d3__relationID: use the __d3__relationID from the userData.

Return Value:
Returns the result of Sequelize dataModel.findAndCountAll() — including total count and an array of rows.

Sample rowsData Output:

{
  count: 1,
  rows: [
    {
      id: 1,
      columnName1: 'columnValue1',
      columnName2: 'columnValue2',
      columnName3: 'columnValue3',
    },
  ],
}

updateOpWithRelation

Usage:

const updatedData = await updateOpWithRelation(
  tableName,
  payload,
  __d3__parentID,
  __d3__relationID
);

tableName: The name of the table must be the main table of the component.
payload: Contains the modified userData for the Create API request.
__d3__parentID: use the __d3__parentID from the userData.
__d3__relationID: use the __d3__relationID from the userData.

Return Value:
Returns the result of Sequelize dataModel.update() — indicating how many records were affected.

Sample updatedData Output:

{
  affectedCount: [1]
}

removeOpWithRelation

Usage:

const deletedData = await removeOpWithRelation(
  tableName,
  payload,
  __d3__parentID,
  __d3__relationID
);

tableName: The name of the table must be the main table of the component.
payload: Contains the modified userData for the Create API request.
__d3__parentID: use the __d3__parentID from the userData.
__d3__relationID: use the __d3__relationID from the userData.

Return Value:
Returns the result of Sequelize dataModel.delete() — indicating how many records were deleted.

Sample deletedData Output:

{
  deletedObjNo: 1
}

bulkCreateOpWithRelation

Usage:

const bulkData = await bulkCreateOpWithRelation(
  tableName,
  payload,
  __d3__parentID,
  __d3__relationID
);

tableName: The name of the table must be the main table of the component.
payload: Contains the modified userData for the Create API request.
__d3__parentID: use the __d3__parentID from the userData.
__d3__relationID: use the __d3__relationID from the userData.

Payload Example:

{
  __d3__bulkData: [
    {
      columnName1: 'columnValue1',
      columnName2: 'columnValue2',
      columnName3: 'columnValue3',
    },
    {
      columnName1: 'columnValue1',
      columnName2: 'columnValue2',
      columnName3: 'columnValue3',
    }
  ]
}

Ensure __d3__parentID and __d3__relationID are passed along with the payload to maintain the relational integrity.

Return Value:
Returns the result of Sequelize dataModel.bulkCreate() — an array of inserted records.

Sample bulkData Output:

[
  {
    columnName1: 'columnValue1',
    columnName2: 'columnValue2',
    columnName3: 'columnValue3',
  },
  {
    columnName1: 'columnValue1',
    columnName2: 'columnValue2',
    columnName3: 'columnValue3',
  }
]
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.