问题
I need to store an array of objects in a Cassandra DB column, for example, I may have a table that has a column named people, which would hold an array of objects:
[
{
name: one,
age: 1
},
{
name: two,
age: 2
}
]
However, looking at the docs, I can't find anything that would be a good data type for this except for people set<blob>
but I'm wondering if there is something more explicit.
回答1:
You can use user defined type (UDT)
Create a UDT Type :
CREATE TYPE people (
name text,
age int
);
Now declare the type of people field :
people set<frozen <people>>
来源:https://stackoverflow.com/questions/45222734/cql-data-type-for-storing-an-array-of-object