Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty Collection to work with "Service" construct #382

Open
Max101 opened this issue May 10, 2024 · 0 comments
Open

Empty Collection to work with "Service" construct #382

Max101 opened this issue May 10, 2024 · 0 comments

Comments

@Max101
Copy link
Contributor

Max101 commented May 10, 2024

Describe the bug
If we specify and empty "" string as a collection name, the service collection does not work thus its not possible to query across all service entities with same PK . This should be possible given with a raw DynamoDb query it is.

ElectroDB Version
Specify the version of ElectroDB you are using
(e.g. 1.8.4)
latest

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

{
      model: {
        service: 'user',
        entity: 'UserFirstName',
        version: '1',
      },
      attributes: {
        user_id: {
          type: 'string',
          required: true,
        },
        first_name: {
          type: 'string',
          required: true,
        },
      },
      indexes: {
        byUserId: {
          collection: '', // Or no collection
          pk: {
            field: 'pk',
            composite: ['user_id'],
          },
          // pk: $user#user_id_
          sk: {
            field: 'sk',
            composite: [],
          },
        },
      },
    },
...

{
      model: {
        service: 'user',
        entity: 'UserLastName',
        version: '1',
      },
      attributes: {
        user_id: {
          type: 'string',
          required: true,
        },
        last_name: {
          type: 'string',
          required: true,
        },
      },
      indexes: {
        byUserId: {
          collection: '', // Or no collection
          pk: {
            field: 'pk',
            composite: ['user_id'],
          },
          // pk: $user#user_id_
          sk: {
            field: 'sk',
            composite: [],
          },
        },
      },
    },

Expected behavior
To be able to query even if there is no collections defined? The issue is, on an existing dataset, where one has not thought of the possibility of a collection being there in the future, its currently impossible to introduce one unless a new entity with a collection is defined and all the data is migrated to that collection.
However, this functionality is possible and easy to query with dynamoDb directly, so is there a way this can be done with ElectroDB or is the only way to have this, to create a collection?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant