Supista
Contact Us
documentation
Supista ERP
Parameters
API Operations
Create Operation

Create Operation

The createOp function is used to insert a new record into a PostgreSQL table.


Usage

const createdData = await createOp(tableName, payload);

Parameters

tableName (Required)

The name of the PostgreSQL table where a new row will be added.

payload (Required)

A modified userData object containing the data to insert under __d3__newData.


Payload Structure

{
  __d3__newData: {
    columnName1: "value1",
    columnName2: "value2",
    columnName3: "value3"
  }
}

Return Value

Returns the result of Sequelize dataModel.create()
a single object representing the newly created record.

Sample Output

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

Example Implementation

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

Example Input

{
  "__d3__newData": {
    "name": "Sample",
    "bio": "Sample",
    "create at": "2025-06-11T09:02:01.794Z"
  }
}

Example Output

{
  "response": {
    "__d3__result": {
      "result": {
        "count": 1,
        "rows": [
          {
            "id": 3,
            "name": "Sample",
            "bio": "Sample",
            "create at": "2025-06-11T09:02:01.794Z",
            "__d3__createdBy": 575,
            "__d3__updatedAt": "2025-06-11T09:08:50.082Z",
            "__d3__createdAt": "2025-06-11T09:08:50.082Z",
            "__d3__lastUpdatedBy": null,
            "__d3__deletedAt": null
          }
        ]
      }
    },
    "__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.