Giter Club home page Giter Club logo

Comments (4)

mobsense avatar mobsense commented on July 2, 2024 1

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.

mobsense avatar mobsense commented on July 2, 2024 1

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.

clemzangrilli avatar clemzangrilli commented on July 2, 2024

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.

clemzangrilli avatar clemzangrilli commented on July 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.