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 = basicIO.getArgument("age");
- let rowData = {
- name: name,
- age: age
- };
- //Use the table meta object to insert the row which returns a promise
- let datastore = app.datastore();
- let table = datastore.table(tablename);
- let insertPromise = table.insertRow(rowData);
- await insertPromise.then((row) => {
- console.log("Row inserted successfully" +JSON.stringify(row));
- basicIO.write(JSON.stringify(row));
- }).catch((err) => {
- console.log("Exception occured :" +err);
- basicIO.write(JSON.stringify(err));
- })
- context.close();
- };
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.