rethinkdb / rethinkdb/docs

Better Example of Key/Value pair iteration

Open
#1,093 0 comments 2 reactions 1 assignee View on GitHub

@chipotle is already working on this.

Since Apr 22, 2016.

enhancement
Dominant language
CSS
Stars
118
Forks
161
PR merge metrics
No merged PRs in 30d

Description

Based on my recent experience coming up to speed on manipulating objects, I'd suggest that the following example should be included somewhere in the API docs. Had I seen it ... would have saved me a lot of time and a lot of head scratching:

r({"a": 1, "b": 2}).do(
  (obj) =>  r.map(obj.keys(), obj.values(), (k, v) => [k, v]).coerceTo('OBJECT'))

I propose that this example be placed in the docs for map, because that's where I first went looking, trying to understand how I could iterate across all key/value pairs. Now, map does already have a tiny comment on this, but I missed it the first few times I looked, because my eye was drawn to the examples, and not the explanatory text.

Note: I personally find the following version harder to grok which is why I propose the version above:

r({"a": 1, "b": 2}).do(
  (obj) =>  obj.keys().map(obj.values(), (k, v) => [k, v]).coerceTo('OBJECT'))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.