Coder Social home page Coder Social logo

Comments (5)

typedorm-bot avatar typedorm-bot commented on May 20, 2024

πŸŽ‰ This issue has been resolved in version 1.6.0-beta.1 πŸŽ‰

The release is available on GitHub release

Your semantic-release bot πŸ“¦πŸš€

from typedorm.

typedorm-bot avatar typedorm-bot commented on May 20, 2024

πŸŽ‰ This issue has been resolved in version 1.7.0 πŸŽ‰

The release is available on GitHub release

Your semantic-release bot πŸ“¦πŸš€

from typedorm.

michael-pont avatar michael-pont commented on May 20, 2024

Hi @whimzyLive
Just wanted to understand the exact behavior of isSparse
From documentation:

(property) isSparse?: boolean
DynamoDB only adds item to index if both Partition Key and Sort Key defined for any given GSI contains value

Indexes missing sort key value will not be added to index.

However, when I define false for a sparseIndex I expect undefined/optional values to be allowed for sort key

    GSI2: {
      partitionKey: 'COMPANY#{{companyId}}',
      sortKey: 'DEPT#{{deptId}}',
      type: INDEX_TYPE.GSI,
      isSparse: false,
    },

...
  @Attribute()
  companyId: string;

  @Attribute()
  deptId?: string;
...

This is not working though when I try to create a new user with companyId defined but deptId empty.
I get the following error:

"deptId" was referenced in DEPT#{
    {deptId
    }
} but it's value could not be resolved.

Additionally, if i define a default value for deptId, the same error occurs, so it appears as if the code here is running before default value is set.

  @Attribute({
    default: '',
  })
  deptId?: string;

So my question is what exactly is the expected behavior when isSparse: false?

from typedorm.

michael-pont avatar michael-pont commented on May 20, 2024

As a followup to my previous comment, I observed the opposite behavior with the same entity but a different index:

    GSI3: {
      partitionKey: 'COMPANY#{{companyId}}',
      sortKey: {
        alias: 'officeStatus',
      },
      type: INDEX_TYPE.GSI,
    },

...
  @Attribute({
    default: OfficeStatus.REMOTE,
  })
  officeStatus: OfficeStatus;
...

When I create a user and leave officeStatus undefined it will create the default value for me and will not throw any error like the one from the previous comment. Querying then with PK = companyId and officeStatus = remote works and returns users

from typedorm.

structurr avatar structurr commented on May 20, 2024

I'm running into the same issue as @michael-pont mentioned above. Please allow sort keys to be optional when defining GSIs on a table.

from typedorm.

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.