Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions udfs/insert_attributes.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
/*
* This UDF is used to insert three new attributes into the message metadata.
* This UDF is used to insert three new attributes into the message.
*
* @param {Object} message - The message to insert attributes into.
* @param {Object} metadata - The metadata to modify.
* @returns {Object} The message with new attributes in metadata.
* @param {Object} metadata - The metadata of the message.
* @returns {Object} The message with new attributes.
*/
function insert_attributes(message, metadata) {

// Parse the message
const data = JSON.parse(message.data);
const attributes = message.attributes;

// Add new attributes to insert
// Add new attributes
attributes["key1"] = 'value1';
attributes["key2"] = 'value2';
attributes["key3"] = 'value3';
attributes["key3"] = 'value3';

// Update the message with modified data
message.data = JSON.stringify(data);

return message;
}