Closed ides15 closed 5 months ago
Looks like I can actually use the CustomAttributeType
to do what I want here:
const Person = new Entity(
{
model: {
entity: "person",
version: "1",
service: "person",
},
attributes: {
name: {
type: "string",
required: true,
},
interestsScore: {
type: CustomAttributeType<Record<string, string>>("any"),
},
},
},
)
Hi @ides15 👋
This is exactly what I was hoping you'd find! Glad you found the answer, let me know if you have any further questions!
I'd like to make an entity that looks like
where the
interestsScore
could basically be a TypeScriptRecord
type, where the keys are unknown:Any attribute with type
map
requires theproperties
key to be set, but I don't know the values of each property beforehand. If I setproperties: {}
, theinterestsScore
field doesn't get type safety - I can setinterestsScore
to a string, boolean, number, etc.How can I create this attribute? Bonus points if I can create a
map
attribute that has string keys, and each value is also a map containing specific properties:Sorry in advance if this is already mentioned in the docs, I must've missed it. Thanks!