CQL data type for storing an array of object

谁说胖子不能爱 提交于 2019-12-24 10:39:36

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!