Day 3 : Batchmode in impex
Another question I screwed up in interviews. I have used batchmode=true multiple times while deleting itemtypes. But haven’t thought it through how it behaves. On most days, I sleep walk through my day. If I had paid even a slight bit of attention, I could have answered this question easily. :(
So why do we use batchmode in impex?
As the name itself suggests, batchmode is used for handling data as a batch.
If explicitly not given, batchmode is always false. In the normal scenarios if our impex unique attribute resolves more than one record, we would get error like multiple records found for update and cannot be updated.
Batchmode is useful when we want to update multiple rows of an itemtype. Usually I clear off some item types using the typecode.
$targetType=Reference
REMOVE $targetType[batchmode=true];itemtype(code)[unique=true]
;$targetType
For updating all the customers with marketingEmail as true
UPDATE Customer[batchmode=true];itemType(code)[unique=true];marketingEmail
;Customer;true