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


    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.

    // JSON equivalent:
    //   { "abilities": { "damage": true, "mana_cost": true }, "weapons": true }
            r.hashMap("damage", true).with("mana_cost", true))
        .with("weapons", true)

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

    // JSON equivalent:
    //   { "abilities": [ "damage", "mana cost" ] }, "weapons"
     .pluck(r.hashMap("abilities", r.array("damage", "mana_cost")), "weapons")

    For more information read the nested field documentation.

    Get more help

    Couldn't find what you were looking for?