【问题标题】:CQL data type for storing an array of object用于存储对象数组的 CQL 数据类型
【发布时间】:2017-07-21 02:43:05
【问题描述】:

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

   [
        {
            name: one,
            age: 1
        },
        {
            name: two,
            age: 2
        }
    ]

但是,查看the docs,除了people set<blob>,我找不到任何适合此的数据类型,但我想知道是否有更明确的内容。

【问题讨论】:

    标签: json cassandra cql


    【解决方案1】:

    您可以使用user defined type (UDT)

    创建一个 UDT 类型:

    CREATE TYPE people (
        name text,
        age int
    );
    

    现在声明人员字段的类型:

    people set<frozen <people>>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-22
      • 2017-07-03
      • 2016-10-27
      • 2023-03-05
      • 2011-08-20
      • 1970-01-01
      • 2014-06-11
      相关资源
      最近更新 更多