Insert Rows
You can insert a new row of data or a record in a table in the Data Store by referring to the table’s unique ID or name. You can also insert multiple rows in a table in the same operation.
You must construct an array containing the rows to be inserted in the table, and pass the array as an argument to the addRow() method as shown below. This inserts the rows in the table you refer to by its unique name or ID. The rows are specified in a {column name : column value} format. The promise returned here is resolved to an object, where the content key contains the array of the rows.
The table reference used in the code below is the table object created earlier.
//Create an array with the rows to be inserted
var details = [
{"Name": "Heather Drake", "Age": 26},
{"Name": "Lucy Park", "Age": 34}
];
//Insert the rows by passing the array, which in turn returns a promise
var datastore = catalyst.table;
var table = datastore.tableId('EmpDetails'); //Provide the table ID or table name to insert the rows
var insertPromise = table.addRow(details); //Pass the JSON array
insertPromise
.then((response) => {
console.log(response.content);
})
.catch((err) => {
console.log(err);
});
A sample response that you will receive is shown below. The response is the same for both versions.
Web SDK
[
{
CREATORID: "2136000000006003",
MODIFIEDTIME: "2021-08-25 13:55:04:904",
Name: "Heather Drake",
Age: 26,
CREATEDTIME: "2021-08-25 13:55:04:904",
ROWID: 2136000000038008
},
{
CREATORID: "2136000000006003",
MODIFIEDTIME: "2021-08-25 13:55:04:906",
Name: "Lucy Park",
Age: 34,
CREATEDTIME: "2021-08-25 13:55:04:906",
ROWID: 2136000000038010
}
]
Last Updated 2026-11-03 13:18:52 +0530 IST
Yes
No
Send your feedback to us