Empty Collection to work with "Service" constructΒ #382
Description
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!