Basic I/O function in Nodejs to insert row in Catalyst Data Store

Basic I/O function in Nodejs to insert row in Catalyst Data Store

  1. const catalyst = require("zcatalyst-sdk-node");
  2. module.exports = async(context, basicIO) => {
  3.     const tablename = "Students"
  4.     const app = catalyst.initialize(context);
  5.     let name = basicIO.getArgument("name");
  6.     let age = basicIO.getArgument("age");
  7.      let rowData = { 
  8.          name: name,
  9.          age: age   
  10.      };
  11.      //Use the table meta object to insert the row which returns a promise
  12.      let datastore = app.datastore();
  13.      let table = datastore.table(tablename);
  14.      let insertPromise = table.insertRow(rowData);
  15.     await insertPromise.then((row) => {     
  16.              console.log("Row inserted successfully" +JSON.stringify(row));
  17.              basicIO.write(JSON.stringify(row));            
  18.          }).catch((err) => {
  19.             console.log("Exception occured :" +err);
  20.             basicIO.write(JSON.stringify(err));
  21.          })
  22.     context.close();
  23. };
    • Related Articles

    • Basic I/O function in Nodejs to insert row in Catalyst Data Store

      const catalyst = require("zcatalyst-sdk-node"); module.exports = async(context, basicIO) => {     const tablename = "Students"     const app = catalyst.initialize(context);     let name = basicIO.getArgument("name");     let age = ...
    • Multiline text fields in the Catalyst Data Store

      You can create your application with multiline text and rich text fields and use the text datatype available in the Catalyst Datastore in order to save the contents of those fields. You can find the help documentation regarding the same here. 
    • Basic I/O Function :Troubleshooting Tips

      Do check in your code whether you have used context.close() anywhere after the function block as it might close the function before sending the response. This might have caused you the issue.  The code within the function block will be executed only ...
    • Basic I/O function doesn't accept request body

      you have created a Basic IO function for which you have sent the payload in request body. For Basic IO functions, the request data should be sent via the query parameters in GET method.
    • Limit of text data type in Catalyst Data Store

      The limit of text datatype in the Catalyst Datastore is 10000. If your message contains more than 10000characters, please consider creating a file in the FileStore and upload the content to it.