hyperledger - Define unique relationships in hyperledger composer
问题描述
I have this simplified scenario:
asset device identified by deviceID
{
o String deviceID
o Data reading
}
concept Data identified by readingID
{
o String ReadingID
o Double Lng
o Double Lat
}
Is it possible to avoid that different devices have the same reading associated, like a unique relationship? An example:
deviceID = 1111 --> readingID = aaaa
deviceID = 2222 --> readingID = aaaa
I am trying to avoid this situation. I tryied to use a relationship using:
asset device identified by deviceID
{
o String deviceID
--> Data reading
}
taking Data as an Asset, but I have the same problem.
解决方案
首先你的模型是:
asset device identified by deviceID
{
o String deviceID
o Data reading
}
concept Data
{
o String readingID
o Double Lng
o Double Lat
}
其次,Composer 中的关系不用于像 RDBMS 那样“强制”唯一性(因为它不使用 RDBMS,它使用键/值存储)。
检查您的设备资产是否尝试使用已与资产关联的 readingID(存储在概念中,隐藏在资产注册表中的资产中)的最简单方法是在注册表上运行查询并使用 true 或 false您的交易代码。除非您将已使用的 ID 作为注册表存储在其他地方,但会增加更多维护等。
推荐阅读
- azure - 无法通过 Azure 自动化帐户使用 azure 资源管理器模板部署 azure 存储
- java - 随机滚动 2 个骰子(java)
- c# - 使用带有结果验证的命令
- php - 如何从服务器获取最新图像(命名为最高编号)以显示在网站上?
- python - 有没有办法修复 django 上的数据库问题?
- android - 如何以编程方式启用 NotificationChannel 声音
- selenium - 快速微调器上的“断言”不起作用 [Selenium IDE]
- c# - Azure 持久功能:处理时间长使功能超时
- python - Python多线程函数参数
- php - 编辑 bootstrap.php 以自定义 Dotenv 行为