rethinkdbrethinkdb-javascriptreql

RethinkDB Query to Find Duplicate Email Addresses (records)


I have the following ReQL Query which Identifies distinct addresses, but can't seem to add the not() method to get the opposite.

r.db('mydb').table('users').orderBy(r.desc('email')).without('id').distinct()

Solution

  • not operates on booleans. .distinct().not() doesn't modify the distinct operation. It just gets applied applies to its result, which doesn't make much sense.

    You could instead do something like this

    r.db('mydb').table('users')
     .group('email').count().ungroup()
     .filter(row => row('reduction').gt(1))('group')