Replies: 1 comment 1 reply
-
Hi @leptonite 👋 Great question! We have a few options, but I want to first address why filters don't go down the usual path that calls There are a number of ways we can address this, but here are the top three stand outs: Option 1Whenever you struggle with a filtering issue, remember that the best part of how the Option 2The next option involves removing the stringification of your Color class, and filtering on the individual properties. This assumes that the stringified value isn't being used since it's serialized on write and deserialized on retrieval. I assume this option won't work for you, while I am interested in your use-case for serializing the value, but I am sure it's part of a bigger requirement. I mention this as an option though because there is actually a mix of option 1 and option 2 next... Option 3Here is another approach for you to consider: the attribute option watch (read more here) was created to make denormalization easier, and I think it might be helpful here! Quick break for story time: one project I had required me to create a "transaction warehouse" that stored user purchase transactions. There was a need to filter by the transaction description (e.g. filter by the term How that relates to your use case is maybe you can have your Let me know if this helps, I can go into more detail on any of the above and/or help you brainstorm more ideas based on your use case 👍 |
Beta Was this translation helpful? Give feedback.
-
I'll refer to this example when describing my issue below.
For an attribute (line 53) of my item I want to use instances of a custom class (line 4). They should be serialized to a string when writing into the DynamoDB table and deserialized into instances of the custom class when reading the table. Furthermore,
EntityItem<...>
should infer the custom class rather than string for this attribute (line 78). This works fine by usingCustomAttributeType
, but my first question is: Did I do it the right way?Next I want to use this attribute in a query like this:
[...].where(({ myAttribute }, { eq }) => eq(myAttribute, new MyCustomClass([...]))).go()
I tried this in three ways (lines 100, 103 and 106) and I expected the version in line 100 to work, but it doesn't. I think it could work, ElectroDB just needs to apply the attribute's set function (line 57) not only to attribute values, but also to query values on this attribute.
Do you agree that ElectroDB should work the way I expected?
If not, how should I write queries on such attributes?
Beta Was this translation helpful? Give feedback.
All reactions