question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not resolve primary key on find.

See original GitHub issue

Hello,

I’m trying to do a simple find on a GSI but I have the error "id" was referenced in ITEM#{{id}} but it's value could not be resolved. even if it’s not used in the request

Here is my code

import { Attribute, AUTO_GENERATE_ATTRIBUTE_STRATEGY, AutoGenerateAttribute, Entity, INDEX_TYPE } from '@typedorm/common';

@Entity({
  name: 'item',
  primaryKey: {
    partitionKey: 'ITEM#{{id}}',
    sortKey: 'ITEM#{{id}}',
  },
  indexes: {
    GSI1: {
      type: INDEX_TYPE.GSI,
      partitionKey: 'PARENT#{{parentId}}',
      sortKey: 'CREATED_AT#{{createdAt}}',
    },
  },
})
export class Item{
  @AutoGenerateAttribute({
    strategy: AUTO_GENERATE_ATTRIBUTE_STRATEGY.UUID4,
  })
  id!: string;

  @Attribute()
  parentId!: string;

  @AutoGenerateAttribute({
    strategy: AUTO_GENERATE_ATTRIBUTE_STRATEGY.EPOCH_DATE,
  })
  createdAt: string;

  @AutoGenerateAttribute({
    strategy: AUTO_GENERATE_ATTRIBUTE_STRATEGY.EPOCH_DATE,
    autoUpdate: true,
  })
  updatedAt: string;
}

// Dynamodb request
const items = await entityManager.find(Item, { parentId: "parent-1", queryIndex: "GSI1" })
// ERROR [ExceptionsHandler] "id" was referenced in ITEM#{{id}} but it's value could not be resolved.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
michael-pontcommented, Dec 9, 2021

I found it here in the docs: https://github.com/typedorm/typedorm/blob/main/docs/guide.md#step-by-step-guide Just ctrl+f for queryIndex.

0reactions
typedorm-botcommented, Mar 14, 2022

🎉 This issue has been resolved in version 1.15.0-beta.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

could not resolve property: composite key in query - Stack ...
I am trying to fetch the list of records from a view which has a composite primary key with three columns.
Read more >
Index or primary key cannot contain a Null value (Error 3058)
Solution. To solve this problem, you must enter a value in the primary key field before moving to another record. See also. Access ......
Read more >
Hubble for JDE: DX - I receive an error that reads: 'Primary key ...
How to resolve the error: 'Primary key validation check failed: Could not find a primary key for table…'
Read more >
Error: Non-Unique value/primary key (or sql_distinct_key ...
If the counts in this query match, the primary key is unique. If the counts do not match, the primary key is not...
Read more >
Troubleshooting migration tasks in AWS Database Migration ...
To solve this issue, the current approach is to first precreate the tables and primary keys in the target database. Then use a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found