Skip to content

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

@pzduniak

Description

@pzduniak
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()
            });
        });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions