Reputation: 85
Currently have a data set with an object of arrays where each array has it's unique id as a key for reference.
"relations": {
"19271934": [
19271894
],
"19621318": [
19621538,
19621586
],
"19788661": [
19788191
],
"19788662": [
19788192
]
}
Would like to create a model for an individual relation so it would be something like this.
relations: types.Map(types.model({
relationId: types.optional(types.array(RelationModel),[])
})),
where the relationId would be the unique id I have no way for knowing before.
Upvotes: 2
Views: 837
Reputation: 112807
You can define it as a map of arrays that contain numbers:
const Store = types.model({
relations: types.map(types.array(types.number))
});
const store = Store.create({
relations: {
"19271934": [19271894],
"19621318": [19621538, 19621586],
"19788661": [19788191],
"19788662": [19788192]
}
});
Upvotes: 3