spring-boot - 如何在 Cassandra 中存储自定义对象?
问题描述
我有以下需要存储在 Cassandra 中的对象。我需要使用 UDT 还是有其他方法来存储对象。我最终需要使用存储库方法从 spring-boot 应用程序中存储它。
{
"name": "Krishna",
"age" : 24,
"address" : [
{
"attributes" : [
{
"name": "",
"value" : ""
}
],
"contactnumbers" : [ "123123234", "123456"]
}
],
"devices" : [
"android_pixel",
"ios_6s"
]
}
解决方案
我认为,您需要在这里使用 UDT。我可以想出这个。
CREATE TYPE attribute_info (
name text,
value text
);
CREATE TYPE address_info (
attributes list<frozen<attribute_info>>,
contactnumbers list<text>
);
CREATE TYPE user_info (
name text,
age int,
address list<frozen<address_info>>,
devices list<text>
);
一旦你得到user_info
你的key space
,在创建或更改表格时将其用作列的类型。
推荐阅读
- python - 在 Simpy 中满足特定条件后继续执行
- excel - Excel如果匹配值然后设置为空
- ajax - 如何通过 ajax 用它的特定数组索引调用这个特定的 api
- html - 从存储在缓冲区中的 HTML 代码中删除行尾等号 (=)?
- node.js - 将带有 mongo db 的 react 应用程序部署到 heroku 时遇到问题
- javascript - 如何遍历 Mongo Collection 并执行 db 操作
- python - 在python中将新值作为字典值添加到列表中
- .net-core - swashbuckle cli 的输出不一致,无法使用脚本任务从本地工作站与构建代理(azure devops)生成 swagger.json
- php - 在 PHP 中使用数值设置 UTC 时区
- sql - 递归 SQL (CTE)