-
Notifications
You must be signed in to change notification settings - Fork 30
Can't conditionally update custom mapped list of strings with empty value #335
Description
Describe the bug
If I have a property with a custom mapper like
@Model() class MyModel { @Property({ mapper: stringArrayOrEmptyMapper }) myList: string[] } export const stringArrayOrEmptyMapper: MapperForType< string[], ListAttribute<StringAttribute> > = { fromDb: attributeValue => attributeValue?.L?.map((item: { S: string }) => item.S) ?? [], toDb: propertyValue => propertyValue?.length ? { L: propertyValue.map(item => ({ S: item })) } : { L: [] }, };
and I try to do a conditional transact update like:
new TransactUpdate(MyModel, PK, SK) .onlyIfAttribute('myList') .eq([]) .updateAttribute('myList) .set(['liststuff'])
I get Error: expected 1 value(s) for operator =, this is not the right amount of method parameters for this operator
This works fine if the list is populated but fails when the list is empty
Expected behavior
I expect the operation to succeed if the list is empty and fail if the list is not empty. I do not expect an error
Activity
Metadata
Metadata
Assignees
Labels
No labels