Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Jorge's example query to other select-intensive RethinkDB queries #145

Closed
pzduniak opened this issue Jun 12, 2015 · 0 comments
Closed
Milestone

Comments

@pzduniak
Copy link

r
.table('labels')
.getAll(owner, { index: 'owner' })
.map(function (label) {
    return r.table('threads')
        .getAll(label('id'), { index: 'labels'})
        .coerceTo('array')
        .do(function (threads) {
            return label.merge({
                'total_threads_count': threads.count(),
                'unread_threads_count': threads.filter(function (thread) {
                    return thread('is_read').not().and(
                        thread('labels').contains(function (label) {
                          return r.expr(spamTrashSent)
                            .map(function (row) { return row('id'); })
                            .contains(label);
                        }).not()
                    )
                }).count()
            });
        });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants