简体   繁体   中英

Orientdb SQL query to check edge properties

I have a Graph database with three simple Vertex types, User, Device and Sensor. The relationship goes as,

Edges: UserHasDevices, DeviceHasSensors

Each edge has a property name "isDeleted". When deleting a Vertex, I don't make it deleted permanently but make the "isDeleted" property of the Edge as "true". Please let me know How to query a list of deleted sensors, and / or deleted list of devices, which belongs to a particular user, identified by user id.

To filter by edges property, you can use outE('edgeName') and put your conditions in some brackets. This is supposed to work according to my understanding :

select expand(outE('UserHasDevices')[isDeleted = true].inV()) from #13:12

In another question , the asker says it doesn't work.

I found another way to do this. You can also expand from the edges. This would look like this :

select expand(in) from UserHasDevices where isDeleted = true and out = #13:12

But I don't think it is the best ideal to store a property in an edge performance wise. The best thing to do would be to have another edge that contains the "isDeleted" vertices. It would be simpler and it would allow you to have a smaller query execution time. This would eliminate the need to filter by the edge property.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM