Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to filter the data being copied? #41

Open
rafcremer opened this issue Oct 8, 2023 · 1 comment
Open

How to filter the data being copied? #41

rafcremer opened this issue Oct 8, 2023 · 1 comment

Comments

@rafcremer
Copy link

rafcremer commented Oct 8, 2023

Hi, is there a way to filter the data that is being copied so I can choose to not copy the records I don't need based on some condition?

Let's say I want to only copy records from one table to another where the CustomerID is the one I specify instead of coping all records.
If I try to do that in the transform function, I get a MultipleValidationErrors error.

It would be helpful if I could define filter expressions to be used with options.source.dynamoClient.scan in your scan method.

@MattWlodarski
Copy link

A workaround I came up with is to return null in the transform function for the items you don't want copied. Then go to your node_modules/copy-dynamodb-table/index.js file and add this line of code to the mapItems functions:

data.Items = data.Items.filter(item => item?.PutRequest?.Item);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants