Insert Rows

Notes:
  • Ensure you have installed the required package to use this SDK method.

  • Ensure that you create the required table and columns in the console.

Insert a Single Row

You can use the insertRow() SDK method, to insert a single row of data to a column in a table in Catalyst DataStore. You can refer to the required table using its ID or name.

The table reference used in the below code snippets can either be a table instance or a table meta.

To use the following SDK method, you need to create a JSON object containing the row details in the following format:

copy
{column name : column value}

This JSON object will then need to be passed as an argument to the insertRow() SDK method.

copy
// Create a JSON object with the rows to be inserted
const rowData = { Name: "George Hamilton", Age: 22, ID: 6868 };
// Use the table meta object to insert the row
const datastore = new Datastore();
const table = datastore.table("EmpDetails");
const row = await table.insertRow(rowData);
console.log(row);

A unique RowID value will be automatically generated once the row is inserted.

Example of Expected Response

copy
{
  "CREATORID": "2136000000006003",
  "MODIFIEDTIME": "2021-08-16 16:29:10:499",
  "Name": "George Hamilton",
  "Age": "22",
  "ID": "6868",
  "CREATEDTIME": "2021-08-16 16:29:10:499",
  "ROWID": 2136000000011011
}

Insert Multiple Rows

You can insert multiple rows to a table in Catalyst DataStore by constructing an array that contains the row data and passing it as an argument to the insertRows() SDK method. You can refer to the required table using its ID or name.

The table reference used in the below code snippets can either be a table instance or a table meta.

copy
// Create a JSON array with the rows to be inserted
const rowData = [
  { Name: "Mark Wellington", Age: 29, ID: 7218 },
  { Name: "Zendaya Jones", Age: 32, ID: 3211 }
];
// Use the table meta object to insert multiple rows
const datastore = new Datastore();
const table = datastore.table("EmpDetails");
const rows = await table.insertRows(rowData);
console.log(rows);

Example of Expected Response

The promise returned when using the insertRows() SDK method is resolved to an array containing the row objects.

copy
[
  {
    "CREATORID": "2136000000006003",
    "MODIFIEDTIME": "2021-08-25 13:55:04:904",
    "Name": "Mark Wellington",
    "Age": "92",
    "ID": "7218",
    "CREATEDTIME": "2021-08-25 13:55:04:904",
    "ROWID": 2136000000038008
  },
  {
    "CREATORID": "2136000000006003",
    "MODIFIEDTIME": "2021-08-25 13:55:04:906",
    "Name": "Zendaya Jones",
    "Age": "32",
    "ID": "3211",
    "CREATEDTIME": "2021-08-25 13:55:04:906",
    "ROWID": 2136000000038010
  }
]

Last Updated 2026-07-02 14:51:41 +0530 IST