I have an "id" string that I'm reading from a change feed in CosmosDB. Each record is versioned, so that whenever the record is updated, the old record will be versioned to include a timestamp, and the new record will be added.
Example:
id: productbase-001.11
GETS UPDATED
id: productbase-001.11 <- new record
id: productbase-001.11-2020-03-30 <- old record
What I want to do is get the type (productbase), then get the itemId (001.11) and get the timestamp (2020-03-30). I only need the timestamp because I want to exclude the old records from my processing logic further down.
foreach (ProcessedItem item in changes)
{
var convert = item.id.Split('-');
string itemType = convert[0];
string itemId = convert[1];
string timestamp = convert[2];
if (timestamp != null)
{
return;
}
else
{
[rest of my code]
}
}
Obviously have a problem will null refs, and also having the "-" as a delimiter will mean that I get "2020" and "03" and "30" all as separate items in the array. Also not sure how slow this will be if I have 3000 updates coming through.
If there is a better way to get these using SQL API, then I am all ears.