Preparation for version 3.0 #424
Replies: 7 comments 10 replies
-
Here are a few suggestions I would like to see:
type Identifier<S extends Service<any>> = keyof S['entities'];
const rawItem =
record.eventName === 'REMOVE'
? unmarshall(record.dynamodb?.OldImage as DynamoDBImage)
: unmarshall(record.dynamodb?.NewImage as DynamoDBImage);
const identifier = '__edb_e__' in rawItem ? (rawItem['__edb_e__'] as Identifier<typeof service>) : undefined;
const entity = service.entities[identifier] as Entity<any, any, any, any>;
const { data } = entity.parse({ Item: rawItem }); |
Beta Was this translation helpful? Give feedback.
-
Thanks for putting these together! Luckily, only the " I'll have to find time to respond more completely but here is one thought I had reading the above:
|
Beta Was this translation helpful? Give feedback.
-
This might also be a good add: #411 |
Beta Was this translation helpful? Give feedback.
-
Hi @tywalch coming back to this, there is another feature I'd like to suggest: an option to ignore attributes: {
createdAt: {
type: 'string',
readOnly: true,
default: () => isoDateTime(),
set: () => isoDateTime(),
},
updatedAt: {
type: 'string',
readOnly: true,
watch: '*',
set: () => isoDateTime(),
},
} My Update APIs which are calling ElectroDB receive a complete entity with these timestamps, because they were returned from another API, and call |
Beta Was this translation helpful? Give feedback.
-
Can I ask the question why you would remove the limit parameter? I use it almost everywhere is there something wrong about it? |
Beta Was this translation helpful? Give feedback.
-
Previously the
(Background you might know, but others often don't) DynamoDB is weird because it doesn't offer a mechanism to retrieve a specific number of items returned. The nature of how Filter Expressions work can result in "empty" reads. DynamoDB queries 1 MB at a time and then applies filters afterward. In the case of an empty receive, there could still be more results to retrieve, but none were found in that 1 MB page.
This is sort of true, though From here, there are two big takeaways:
|
Beta Was this translation helpful? Give feedback.
-
I'm sorry for not getting back to you sooner! Here are a few responses:
Yes, because you are narrowing your queries complete with indexes, this should work just fine 👍 The exception here is if you're using a clustered index (more info below).
Yes, that is one scenario. Another scenario is when you use clustered indexes. In single table design, sometimes other entities can be returned by a query request; ElectroDB will filter these out for you before returning a response, but that's another example of getting an "empty" response. It is best always to expect that DynamoDB will not give you back any items, but if it returns a cursor, there is still more to query.
Your first example could and should still use a refresher for future readers:
DynamoDB changes you for items evaluated on their side. Non-index filters are applied after retrieval so they will never reduce cost. Using |
Beta Was this translation helpful? Give feedback.
-
I am collecting a list of changes for v3.0.0 so that I can address as many breaking changes in one version as possible. Here are a few (in no particular order):
Remove all automatic filtering and key shifting from comparison queries
This approach was ultimately ill advised for the library to try and own. It results in confusion and unexpected results. This would remove any filters automatically added by electro.
Remove
conversion
properties from EntityBreaking off conversion from the Entity instance into a utility function will reduce the footprint of the Entity interface
[Maybe] Remove special query
limit
logic:The execution option limit does more than just add a
Limit
parameter to a query, it will paginate until the limit of a query is at least reached. I am labeling this maybeThis is the list currently, let me know if you have any additions you'd like to see!
Beta Was this translation helpful? Give feedback.
All reactions