Reputation: 151
I want to store edges in an ordered way using the pyorient
API.
According to an outdated API page, there are a few examples using the Java API, e.g.
person.createEdgeProperty(Direction.OUT, "Photos").setOrdered(true);
And equivalently in SQL:
orientdb> CREATE PROPERTY out_Photos LINKLIST
orientdb> ALTER PROPERTY User.out_Photos CUSTOM ORDERED=TRUE
I would like to do the same thing using pyorient
but none of the documentation I've seen even hints that this is possible.
Upvotes: 0
Views: 74
Reputation: 151
One hacky way to do it, possibly the only way, is to use the command
function to issue SQL queries.
For edges that already exist, this requires deleting all the edges first, then creating the LINKLIST edge property (see code below):
client.command("""
CREATE PROPERTY Project.in_WorkedOn LINKLIST
ALTER PROPERTY Project.in_WorkedOn CUSTOM ORDERED=TRUE
""")
And then adding all the edges back. By default the ordering will be based on edge creation order.
To set the ordering, do something like so:
client.command("""
UPDATE #120:1 SET in_WorkedOn = [#228:4, #229:2, #228:3, #229:3]
""")
Upvotes: 0