Comments (4)
Can you run with logging enabled so we can see the actual query being run.
I think if a template is incomplete - i.e. component fields are not provided, then the field is not supplied.
You could set the externalId to "" and that will probably work.
from dynamodb-onetable.
If you do a "find" / query and supply only the GSI PK, you will get all the items with that PK.
You can update items and provide the empty string externalId, that will then create the GSI item.
This is a facet of both OneTable and DyanmoDB. DynamoDb will create the item in the GSI only when complete keys are provided. OneTable will not provide a partial GSI SK. You must provide all the key components to create/update a GSI item. i.e. there must be a unique key to identify the item. When doing a find/query, you can provide only the GSI PK and it will return all matching items.
from dynamodb-onetable.
Thank you for your response. Yes, it works if I manually set the 'externalId' to "".
I think you are right, and this is inherent to dynamodb :
A global secondary index only tracks data items where its key attributes actually exist (doc aws).
--> However, I would like to be able to query all my items with the gs1pk, i.e. my 'siteId' property. Do you have a recommendation in this case ?
Possibility nĀ°1 : Create another gsi with 'siteId' only and no gsk.
Possibility nĀ°2 : Manually set externalId to "" at each creation. How do we do for existing items ? Update on all items to set 'externalId' to "" ?
Log of the request whithout externalId, gs1sk not provided
{
"cmd": {
"ConditionExpression": "(attribute_not_exists(#_0)) and (attribute_not_exists(#_1))",
"ExpressionAttributeNames": {
"#_0": "pk",
"#_1": "sk"
},
"TableName": "clementdev-ckl-project-service-dynamodb-table",
"Item": {
"pk": {
"S": "resource#7fdfac2e-63f6-4456-8d39-2c58e0c5bc7d"
},
"sk": {
"S": "resource#"
},
"gs1pk": {
"S": "resource#14ae59fe-2783-4501-912b-85bba7507921"
},
"id": {
"S": "7fdfac2e-63f6-4456-8d39-2c58e0c5bc7d"
},
"siteId": {
"S": "14ae59fe-2783-4501-912b-85bba7507921"
},
"_type": {
"S": "Resource"
}
},
"ReturnValues": "NONE"
},
"items": [
{
"id": "7fdfac2e-63f6-4456-8d39-2c58e0c5bc7d",
"siteId": "14ae59fe-2783-4501-912b-85bba7507921",
}
],
"op": "put",
"properties": {
"pk": "resource#7fdfac2e-63f6-4456-8d39-2c58e0c5bc7d",
"sk": "resource#",
"gs1pk": "resource#14ae59fe-2783-4501-912b-85bba7507921",
"id": "7fdfac2e-63f6-4456-8d39-2c58e0c5bc7d",
"siteId": "14ae59fe-2783-4501-912b-85bba7507921",
"_type": "Resource"
},
"params": {
"parse": true,
"high": true,
"exists": false,
"log": true,
"checked": true
}
}
from dynamodb-onetable.
That confirms what I thought. It would be great to have a warning from the library when the developer is in this scenario, because it can be a significant problem when they find out that the GSI is not updated because due to a null value.
Thank you again for your help.
from dynamodb-onetable.
Related Issues (20)
- params.fields are not respected when using table.getItem() or table.queryItems()
- Metrics.d.ts should not include function interfaces declared as 'async' HOT 7
- Improve: Prohibit the removal of nested object required fields. HOT 1
- Feature: Across entities query HOT 3
- Empty strings are filtered out HOT 2
- Cannot resolve type when ESM HOT 3
- Compound global index not updated if only 1 of 2 properties passed to the update function HOT 1
- Updating unique template field does not remove unique record HOT 2
- "CredentialsProviderError: The SSO session associated with this profile has expired" in "overview" sample... HOT 2
- Connecting OneTable to a local dynamodb instance
- Support for Mapped Types HOT 1
- Please Help: Update Problem (referenced attribute) HOT 3
- OneSchema type for getCurrentSchema() not set HOT 2
- Update operation does not remove object from array HOT 1
- Help: retrieving items by GSI1 HOT 1
- nested props are not getting mapped correctly with map attribute
- Getting error while update on object that contains undefined attribute value in it. HOT 2
- Cannot Transparently Pass On JSON String From Previously Unncrypted Field HOT 1
- queryItems requires { hidden:true } to support groupByType for AWS SDK v3 HOT 4
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-onetable.