Create API
Below is a sample implementation of a customized Create API in Supista ERP:
async function customizeERP(userData, apiOperations) {
const tableName = "Your Table Name";
const { createOp } = apiOperations;
return new Promise(async (resolve, reject) => {
const payload = {
"__d3__newData": {}
};
const createdData = await createOp(tableName, payload);
resolve(createdData);
});
}Output structure
{
"result": {
"id": 12,
"columnName1": "newValue1",
"columnName2": "newValue2"
}
}Read API
Below is a sample implementation of a customized Read API in Supista ERP:
async function customizeERP(userData, apiOperations) {
const tableName = "Your Table Name";
const { readOp } = apiOperations;
return new Promise(async (resolve, reject) => {
const payload = {
"__d3__filterdata": {
"where": {}
}
};
const rowsData = await readOp(tableName, payload);
resolve(rowsData);
});
}Output structure
{
"result": {
"count": 2,
"rows": [
{
"columnName1": "newValue1",
"columnName2": "newValue2"
},
{
"columnName1": "newValue1",
"columnName2": "newValue2"
}
]
}
}Update API
Below is a sample implementation of a customized Update API in Supista ERP:
async function customizeERP(userData, apiOperations) {
const tableName = "Your Table Name";
const { updateOp } = apiOperations;
return new Promise(async (resolve, reject) => {
const payload = {
"__d3__newData": {},
"__d3__id": 12
};
const updatedData = await updateOp(tableName, payload);
resolve(updatedData);
});
}Output structure
{
"result": {
"affectedCount": [1]
}
}Delete API
Below is a sample implementation of a customized Delete API in Supista ERP:
async function customizeERP(userData, apiOperations) {
const tableName = "Your Table Name";
const { removeOp } = apiOperations;
return new Promise(async (resolve, reject) => {
const payload = {
"__d3__id": [12]
};
const deletedData = await removeOp(tableName, payload);
resolve(deletedData);
});
}Output structure
{
"result": {
"deletedObjNo": 22
}
}