Back to top

    ReQL command: pluck

    Command syntax

    sequence.pluck([selector1, selector2...]) → stream

    array.pluck([selector1, selector2...]) → array

    object.pluck([selector1, selector2...]) → object

    singleSelection.pluck([selector1, selector2...]) → object

    Description

    Plucks out one or more attributes from either an object or a sequence of objects (projection).

    Example: We just need information about IronMan’s reactor and not the rest of the document.

    r.table('marvel').get('IronMan').pluck('reactorState', 'reactorPower').run(conn)
    

    Example: For the hero beauty contest we only care about certain qualities.

    r.table('marvel').pluck('beauty', 'muscleTone', 'charm').run(conn)
    

    Example: Pluck can also be used on nested objects.

    r.table('marvel').pluck({'abilities' : {'damage' : True, 'mana_cost' : True}, 'weapons' : True}).run(conn)
    

    Example: The nested syntax can quickly become overly verbose so there’s a shorthand for it.

    r.table('marvel').pluck({'abilities' : ['damage', 'mana_cost']}, 'weapons').run(conn)
    

    For more information read the nested field documentation.

    Get more help

    Couldn't find what you were looking for?