You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @davidmorgan, I have a User entity defined with built_value and including a BuiltMap. I use StandardJsonSerializer to produce objects I persist to Firestore. I'd like to specify a custom serializer for the BuiltMap field so that it's serialized to an object with shape { ids: [...], entities: {...} }.
The reasons for this are: 1) we need to maintain insertion order and Firestore reorders map keys alphabetically; 2) we can't simply serialize the map to a list because some Firestore lookups only work on maps. This pattern is common enough that Redux offers a standardized solution.
Could you give me a hint on the best way to accomplish this? Thank you!
The text was updated successfully, but these errors were encountered:
This is a built_value question rather than a built_collection question :) so please re-open over there if you still have questions.
You could replace the existing BuiltMap serializer with a fully custom one, i.e. write a replacement for the built-in BuiltMapSerializer. This only works if you want allBuiltMap fields to work like that.
Otherwise, I'm afraid there isn't a way to set a different serializer per field--it's always based on type. I think you'd need to create your own type which is basically a copy of BuiltMap but comes with its own serializer.
Hi @davidmorgan, I have a
User
entity defined withbuilt_value
and including aBuiltMap
. I useStandardJsonSerializer
to produce objects I persist to Firestore. I'd like to specify a custom serializer for theBuiltMap
field so that it's serialized to an object with shape{ ids: [...], entities: {...} }
.The reasons for this are: 1) we need to maintain insertion order and Firestore reorders map keys alphabetically; 2) we can't simply serialize the map to a list because some Firestore lookups only work on maps. This pattern is common enough that Redux offers a standardized solution.
Could you give me a hint on the best way to accomplish this? Thank you!
The text was updated successfully, but these errors were encountered: