Skip to content

ProjectionExpression is not created during batchGet and specifying attributes to return #516

@anatolzak

Description

@anatolzak

Describe the bug
When doing batchGet and specifying attributes to return, ElectroDB does not send the ProjectionExpression parameter.

However, ElectroDB still returns only the attributes I specified, but DynamoDB sends more data to the client than necessary due to the missing ProjectionExpression param.

ElectroDB Version
3.4.3

ElectroDB Playground Link
https://electrodb.fun/?#code/PQKgBAsg9gJgpgGzARwK5wE4Es4GcA0YuccYGeqCALgUQBYCG5YA7llXWAGbZwB2MXGBDAAUKKwBbAA5QMVMAG8wAUT5V2AT0IBlTADcsAY1IBfbhiiSwAIkRwjVSzABGNgNzijUPrgVUGFwRSAF5bTShUDAB9AKC4aL4GSTgPcVAwABUGXABrITUNKk1hMW9ffxz8sDC+OBZVdS0AClEwJTb2sElYRAAuDq6u-iLNAZsAvNwbfE6h-UxcLB9xgEYZua7iDEMTccnchmlpG03TWaGGKicsF1QqPAHFTfasGCewYuk4AYByP2wfAA5r9COQ0FhyO9Phh0GBTGcLl0sAI4AAPR6DIZgaSWABWDhoTxeXWkuWJ2OxXBwCGhNjJG0pQ28MigSweAwA2jY3jYALok9rnQVEclYpncGl0vKMiVgFmydk-MCcgUShGUjVdLXC9rKOLBeGiACUnlEB1wADogXAqM1Oco3n83r94XzjdaoM1nu0rjc7g9cFzfi6BaZjUA

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

const tasks = new Entity(
  {
    model: {
      entity: "tasks",
      version: "1",
      service: "taskapp"
    },
    attributes: {
      id: { type: 'string', required: true }
    },
    indexes: {
      projects: {
        pk: {
          field: "pk",
          composite: ["id"]
        },
        sk: {
          field: "sk",
          composite: []
        }
      }
    }
  },
  { table }
);

Expected behavior
When doing batchGet and specifying attributes to return, ElectroDB should create the ProjectionExpression parameter to prevent sending unnecessary data from DynamoDB to the client.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions