如何在ObjectBox C中进行关系查询++
schema.fbs
table Slot {
/// objectbox:id
id : ulong;
defaultlinkoffset : int32;
/// objectbox:relation=Device
parentid : ulong;
}
table Device {
/// objectbox:id
id : ulong;
hid : string;
}
我可以插入和查询表,没有问题
插入
tableDevice_.put({.id = 0, .hid = hid});
查询
std::string hid = "test";
obx::QueryBuilder<Device> qb = tableDevice_.query(Device_::hid.equals(hid, true));
obx::Query<Device> query = qb.build();
query.find();
插槽和设备之间存在多对一的关系,1个插槽可以有多个设备。Slot parentuid不能设置为数组/向量-C++端的文档是稀疏的,但在测试中只支持字符串、字节和ubyte的向量。
C++测试:
https://github.com/objectbox/objectbox-generator/blob/main/test/comparison/testdata/fbs/typeful/schema.fbs
Java文档显示您可以使用ToMany<关系>数据C++版本有类似的功能吗?
Java文档:
https://docs.objectbox.io/relations
我还通过查看Java文档尝试了一个关系查询,但它没有构建
obx::QueryBuilder<Slot> builder = tableSlot_.query(Slot_::defaultlinkoffset.equals(123));
builder.link(Slot_::parentid).equals(Slot_::parentid, "123");
这对于C++版本来说可能吗?有什么例子吗?