I'm a beginner in working with typescript, and I'm currently attempting to extract data from fields in DynamoDB using typescript. My goal is to split a string field into two substrings and store them in separate variables.
Here is an example of the data:
Id days end createdAt type
123 3 2021-07-22#AM 21/10/2020 Leave#Upskilling
342 7 2021-10-22#PM 15/02/2021 Long Term Leave#Parental
The desired output would look like this:
Id days end createdAt type subleavetype
123 3 2021-07-22#AM 21/10/2020 Leave Upskilling
342 7 2021-10-22#PM 15/02/2021 Long Term Leave Parental
This is the snippet of code that I have been working on:
recordsToJoin.push(
getAttributeValue(newImage.id),
getAttributeValue(newImage.days),
getAttributeValue(newImage.end),
getAttributeValue(newImage.createdAt, true),
getAttributeValue(newImage.type.split('#')[0])),
getAttributeValue(newImage.type.split('#')[1]),
);
However, I am encountering errors while trying to run this code. Any assistance would be greatly appreciated.
Below is the file where we call the 'getAttributevalue' function:
import { AttributeValue } from 'aws-sdk/clients/dynamodb';
import { decodeTimestamp } from '../dates/dates';
export const getAttributeValue = (
attribute: AttributeValue,
isDate = false,
): string => {
// Function logic goes here
};
export const getCommaSeparatedValues = (
attributeList: AttributeValue[],
): string => {
// Function logic goes here
};
The error message I'm receiving is: Property 'split' does not exist on type 'AttributeValue'.