Tolerate missing identifier when applySnapshot to map #2241
-
I'm writing an API, and I'd love to just However for a export const StageData = model({
unit: frozen<LengthUnits>(),
latest: Sample,
max: map(Period),
});
// create instance and toSnapshot:
{
unit: 'ft',
latest: { ts: '2025-01-16T00:09:47.392Z', value: 1 },
max: { P1D: { period: 'P1D', sample: [Object] } }
} (note If I omit
As a workaround I can include the duplicate Since each object in a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @davetapley - thanks for the write up here. I don't think we can make this work by default with all
This is only true if you are using a model type that has an identifier. But for some data, you may not use Can you share with me more about an ideal solution? What do you want the snapshots to look like instead? I am not sure if I can really picture how we would snapshot a map of objects with IDs, but not include the keys in the map or the IDs in the objects, but maybe I'm misunderstanding. |
Beta Was this translation helpful? Give feedback.
Hey @davetapley - thanks for the write up here. I don't think we can make this work by default with all
types.map
instances, because this is not always the case:This is only true if you are using a model type that has an identifier. But for some data, you may not use
types.identifier
at all, so we can't guarantee being able to infer things.Can you share with me more about an ideal solution? What do you want the snapshots to look like instead? I am not sure if I can really picture how we would snapshot a map of objects with IDs, but not include the keys in the map o…