question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using order_by with Relationship Properties

See original GitHub issue

I see in the documentation that I can use obj.rel.order_by('prop_name') to order the relatives by the given node property. But what if I want to order by a relation property? Something like this:

class OrderedRel(StructuredRel):
    order = IntegerProperty(required=True)

class Item(StructuredNode):
    ...

class NodeSequence(StructuredNode):
    item = RelationTo('Item', 'ITEM', model=OrderedRel)

for item in node_sequence.item.order_rel_by('order'):
    ...

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:3
  • Comments:7

github_iconTop GitHub Comments

1reaction
Andy-Gengcommented, Jan 3, 2018

Then? Any solution?

0reactions
zacharymostowskycommented, Oct 26, 2020

Any update on this? I was hoping to encode an “active” attribute in a relationship and use that to filter my queries. I will try the suggestions above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Order by relationship properties neo4j - Stack Overflow
I'm fine using ORDER BY with node properties, but have not been successful with relationships (story of my life...) neo4j · sql-order-by ·...
Read more >
Order by on relationship field - Laracasts
This is why we can't order by a relation field. SELECT * FROM users; SELECT * FROM roles WHERE id IN (1, 2,...
Read more >
ORDER BY - Cypher Manual - Neo4j
You can order by multiple properties by stating each variable in the ORDER BY clause. Cypher will sort the result by the first...
Read more >
Ordering database queries by relationship columns in Laravel
In this article we're going to explore how to order database queries by the value (column) of an Eloquent relationship.
Read more >
Laravel Eloquent: Order By Relationship - Two Ways - YouTube
Quite a regular task, but not a simple solution: how to order query results by a belongsTo relation column? I will show you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found