用于存储对象数组的CQL数据类型 [英] CQL data type for storing an array of object

查看:122
本文介绍了用于存储对象数组的CQL数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Cassandra DB列中存储对象数组,例如,我可能有一个表,该表具有名为people的列,该列将容纳对象数组:

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
        }
    ]

但是,请查看文档,除people set<blob>之外,我找不到适合该数据类型的任何内容,但我想知道是否还有更明确​​的内容.

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.

推荐答案

您可以使用

You can use user defined type (UDT)

创建UDT类型:

CREATE TYPE people (
    name text,
    age int
);

现在声明人员类型字段:

Now declare the type of people field :

people set<frozen <people>>

这篇关于用于存储对象数组的CQL数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆