Comments (2)
Hi @justynspooner! Thanks for the note. Every entity needs to have a partitionKey
(and sortKey
if applicable) on the PRIMARY INDEX. Secondary indexes are copies of the data, so in order to actually add the data to DynamoDB, it needs to be added to the Primary Index first, and will then get copied over to secondary indexes if they exist. This is not a function of the library, but of DynamoDB.
So in your example above, your entity would also need to specify a partitionKey:true
and a sortKey:true
on two of your attributes. If you are reusing your sk
as the partitionKey of your GSI1, then your config should look like this:
const MyEntity = new Entity({
name: "MyEntity",
attributes: {
pk: { partitionKey: true },
sk: { sortKey: true, partitionKey: "GSI1"},
data: {sortKey: "GSI1"},
},
table: MyTable
});
Hope that makes sense,
Jeremy
from dynamodb-toolbox.
That makes perfect sense now that I see it laid out like that. Might be worth adding a small example like that to the docs for those newer to DynamoDB like myself. Thank you for the quick reply I'll go and fix my code 😄
from dynamodb-toolbox.
Related Issues (20)
- retrieve auto-generated partition key HOT 1
- EntityItem type infer not work HOT 3
- Typescript issue while declaring entity HOT 10
- ⭐️ Support for batch operations (get & put)
- ⭐️ Support for transactions
- Provided key element does not match the schema HOT 5
- Type inference for batch operations
- get,put,update method type inference incorrect when extending Entity HOT 3
- Document that `type: "set"` and `convertClassInstanceToMap: true` do not go well together HOT 1
- Attributes with defaults that have depend on unresolvable attribute should be ignored
- Type Inference Issue with `Entity.get()` When Used Inside a Class Constructor HOT 10
- Derived state HOT 5
- Invalid Entity ? Is it related to the some version ? HOT 1
- Type inference of entity using EntityItem<typeof MyEntity> not resolving alias HOT 1
- Inferred Type cannot be named without reference to "ts-toolbelt" HOT 4
- Overlays break many constructor inputs HOT 1
- Error when importing abstraction that uses dynamodb-toolbox HOT 1
- Bug on Item.get, where unneeded properties are required HOT 2
- Error when sending EntityV2 `GetItemCommand` with property of type `binary()` HOT 3
- Undefined dependencies for Index keys cause Update / Put failures
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dynamodb-toolbox.