shiftcode / dynamo-easy

DynamoDB client for NodeJS and browser with a fluent api to build requests. We take care of the type mapping between JS and DynamoDB, customizable trough typescript decorators.
https://shiftcode.github.io/dynamo-easy/
MIT License
204 stars 27 forks source link

Using contains conditional with @CollectionProperty #345

Closed vberistain closed 3 years ago

vberistain commented 3 years ago

Describe the bug Can't use contains conditional with a list attribute.

To Reproduce

My model:

@Model()
class Item {
    @PartitionKey()
    id: string;

    @CollectionProperty()
    groupIds: string[];
}

My query (scan):

const items: Item[] = await itemStore
            .scan()
            .whereAttribute('groupIds')
            .contains(["ecb4b030-a4e6-11eb-8c07-f9fa6efb8c80", "8ff5ca30-a4e8-11eb-b3ad-cb2de6cf945b"])
            .exec();

I get the following error in response:

Type L of {\"L\":[{\"S\":\"ecb4b030-a4e6-11eb-8c07-f9fa6efb8c80\"},{\"S\":\"78c49850-a4e8-11eb-8be5-535d967d1ee5\"},{\"S\":\"8ff5ca30-a4e8-11eb-b3ad-cb2de6cf945b\"},{\"S\":\"7f68a590-a4e6-11eb-85d7-a327cfbc3c11\"}]} is not allowed for contains condition. Valid types are: N. S. B

I can't figure out what am I missing here.

Thanks in advance.