yasithlokuge
yasithlokuge

Reputation: 263

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.

Upvotes: 2

Views: 2596

Answers (1)

AlexB
AlexB

Reputation: 3548

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.

Upvotes: 3

Related Questions