tywalch / electrodb

A DynamoDB library to ease the use of modeling complex hierarchical relationships and implementing a Single Table Design while keeping your query code readable.
MIT License
956 stars 58 forks source link

key should be case sensitive #369

Closed LaurenceHo closed 3 months ago

LaurenceHo commented 3 months ago

Describe the bug When I use "get" method to get an object e.g

const response: QueryResponse<typeof this._entity> = await this._entity
      .get({id: "Apple-and-Orange"})
      .go();

I cannot get this object, which exists in DynamoDB. So I placed the logger into entity, and I found out the "id" became lower case. Here is part of log:

queryKey { id: "Apple-and-Orange" }

{
    "type": "query",
    "method": "get",
    "params": {
        "Key": {
            "id": "apple-and-orange"
        },
        "TableName": "my-table"
    },
    "config": {
        "includeKeys": false,
......

ElectroDB Version 2.13.1

ElectroDB Playground Link N/A

Entity/Service Definitions Include your entity model (or a model that sufficiently recreates your issue) to help troubleshoot.

{
    model: {
        entity: "my_entity",
        service: "my_service",
        version: "my_version"
    },
    attributes: {
        prop1: {
            type: "string"
        },
        prop2: {
            type: "string"
        }
    },
    indexes: {
        record: {
            pk: {
                field: "pk",
                composite: ["prop1"],
            },
            sk: {
                field: "sk",
                composite: ["prop2"],
            },
        }
    }
}

Expected behavior Key should be case-sensitive rather than converted to lower case.

Errors

Cannot find the object from Electrodb but it exists in DynamoDB.

Additional context Add any other context about the problem here.

LaurenceHo commented 3 months ago

For anyone who is running into the same issue as me, we can add casing in the index. Please check this doc.