Skip to content

Proposal: allow lambdas in merge #1167

Closed

Description

@coffeemug

This way instead of doing

r.table('users').groupBy('location', r.avg('salary')).map(function(row) {
    return row.merge({ users: r.table('users').filter(function(user) {
        return user('location').eq(row('group'));
    }).coerceTo('array')});
})

One could do

r.table('users').groupBy('location', r.avg('salary')).merge(function(row) {
    { users: return r.table('users').filter(function(user) {
        return user('location').eq(row('group'));
    }).coerceTo('array');}
})

Activity

  1. wmrowan commented on Jul 12, 2013

    @wmrowan
    Contributor

    This is a lot like how update works. If merge supported this behavior then we could get close to a pretty intuitive mapping between "regular" operations and "side-effecting" operations:

    merge <==> update
    do/map <==> replace
    append <==> insert
    

    If we think through this idea we might be able to round out the mapping with a few more tweaks like this here and there.

  2. jdoliner commented on Jul 12, 2013

    @jdoliner
    Contributor

    Since we already have an issue in this milestone which is a week over our timeboxing period for discussion and we're already behind schedule and having our timeboxing methods break down could we not add an issue to a release 3 weeks after the proposal period? This is explicitly against our scheduling rules.

  3. coffeemug commented on Jul 12, 2013

    @coffeemug
    ContributorAuthor

    Err, I don't know how it ended up in 1.8-required (either someone moved it or I made a boo-boo). That was definitely unintentional.

  4. jdoliner commented on Jul 12, 2013

    @jdoliner
    Contributor

    No worries, we'll probably get this in in 1.9.

  5. coffeemug commented on Oct 23, 2013

    @coffeemug
    ContributorAuthor

    Closing as dup of #1345.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions