Trying to add secondaryIndex with a projection ty...
# sst
m
Trying to add secondaryIndex with a projection type of INCLUDE and add the NonKeyAttributes as well. Is there more in-depth documentation on structuring objects in sst or anything that explains how to do this properly (if it even can be done). This is what I am trying, but it is throwing an error on the projectionType field 35:29 error ‘ProjectionType’ is not defined no-undef
f
Hey @mathewgries, can you try adding this to the top of the stack:
Copy code
import { ProjectionType } from "@aws-cdk/aws-dynamodb";
And run
npm run add-cdk @aws-cdk/aws-dynamodb
at the app root.
m
I can’t run that command: missing script: missing script: add-cdk
f
Can I see your package.json?
m
I ran this to see if it would fix it: npm install @aws-cdk/aws-dynamodb
This is the package.json after running the install
f
Ah yeah, if you can change the
aws-dynamodb
line to:
Copy code
"@aws-cdk/aws-dynamodb": "1.114.0",
Just to keep the CDK dependency version consistent
m
sorry, was AFK for a bit. Trying it out now
That allows me to import the “ProjectionType” object. Still not sure how on to structure the NonKeyAttributes within the index though. If I include an object nonKeyAttributes: {} it tells me nonKeyAttributes.forEach is not a function Without, it tells me I need the object lol 🤷‍♂️ I am searching the webs, but not sure if I am using the correct key words for the search to pull what I need yet
f
Can you try passing in an array?
Copy code
nonKeyAttributes: ["SK", "accountName", ...],
m
@Frank We got it. Thank you for the assistance Resolution: npm install @aws-cdk/aws-dynamodb Add to the top of the file import { ProjectionType } from “@aws-cdk/aws-dynamodb”; Add the indexProps object like so:
f
Awesome! Glad it’s working.