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.

Question: how to create a "where without" clause?

See original GitHub issue

Hello!

First wanted to thank you on creating this library, itā€™s been super helpful as Iā€™ve been starting to explore graph databases.

I currently have the following relationships set up:

User - Follows -> User

Iā€™m trying to create a Recommendations query to grab a list of recommended Users that Follows Users that the Current User directly Follows. So essentially User vertices that are two-hops away on the Follows edge.

However, I want to exclude the current User from that list as well as any Users that the Current User directly Follows (anything one-hop away on the Follows edge)

I found within the tinkerpop documentation for Recommendations how to achieve this and was able to get the desired result with the following query (http://tinkerpop.apache.org/docs/current/recipes/#recommendation):

g.V().has('id', '{user_id}').as('self').out('Follows').aggregate('direct-follows').out('Follows').where(neq('self')).where(without('direct-follows'))

Trying to use Gremlinq, I came up with the following:

await _g
    .V<User>(userId)
        .As((_, self) => _
            .Out<Follows>()
            .Aggregate((__, directFollows) => __
                .Out<Follows>()
                .OfType<User>()
                    .Where(x => x != self
                        && !directFollows.Contains(x)))) // How to exclude directFollows?
                .OfType<User>()
                .ToArrayAsync();

which works up until the directFollows.Contains(x) expression in which case it returns the ExpressionNotSupportedException.

Iā€™ve been able to replicate it by combining the results of two separate queries but that seems inefficient:

Example

Is this the correct way to approach this or is there a better way? Or is this functionality just not yet supported?

Thanks šŸ˜ƒ

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
drewyoungdevcommented, Feb 27, 2020

Worked as expected with the original query as expected! Thank you šŸ‘

1reaction
danielcwebercommented, Feb 21, 2020

Well, it should work as intendedā€¦will investigate in a couple of days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Where clause without operator - mysql
In a WHERE clause, MySQL evaluates the expression as a boolean value. If the result of that expression is TRUE, the row is...
Read more >
How to Write a WHERE Clause in SQL
This article covers how to use the SQL WHERE clause in detail, with practical examples using sample data sets.
Read more >
13.2.15.6 Subqueries with EXISTS or NOT EXISTS
If a subquery returns any rows at all, EXISTS subquery is TRUE , and NOT EXISTS subquery is FALSE . For example: SELECT...
Read more >
Best practices for writing SQL queries
SQL best practices: a brief guide to writing better SQL queries. Ā· Correctness, readability, then optimization: in that order Ā· Make your haystacks...
Read more >
Difference between Where and Having Clause in SQL
1. WHERE Clause is used to filter the records from the table based on the specified condition. Ā· 2. WHERE Clause can be...
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