mergeAll Calculations

#1

I need to update fields in a Casandra type by a factor of X. I am trying something like this.

MyType.mergeAll({filter:“fKeyId = 1”}, {quantity: quantity * .8)

Are expression possible in a mergeAll?

0 Likes

#2

I don’t believe this is supported, but a good way to do this could be to use a BatchJob.
Here’s an example: JS Batch job example

0 Likes

#3

Also, a word of caution. Any attempt like this isn’t idempotent, so if the batch job fails part way through, for whatever reason (or a particular batch needs to be retried to do a retryable error), individual records may/will be processed twice, thus corrupting your data.

0 Likes

#4

Thank you for the help @rileysiebel. I was able to use mergeBatch.

@trothwein Thank you for the warning. I plan on creating new fields or add an indicator field that the row/batch has been updated.

0 Likes