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.
-
The table and the columns in it must already be created. You can create a table and the columns for it from the console.
-
You will be able to insert upto 5000 records in each table per project in the development environment. You can create upto 25,000 records overall in each project in the development environment. There are no upper limits for record creation in the production environment.
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.
copy//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
copy[ { 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 2023-11-14 13:20:49 +0530 +0530
Yes
No
Send your feedback to us