Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support picking array elements #5

Closed
foobar450 opened this issue Apr 14, 2015 · 3 comments
Closed

Support picking array elements #5

foobar450 opened this issue Apr 14, 2015 · 3 comments

Comments

@foobar450
Copy link

I am trying to acheive the following:

var data = {
  foo: [
    { text: 'bar1' },
    { text: 'bar2' }
  ]
};

console.log(dot.pick('foo[0].text', data));  // Expected result: 'bar1'

However, the current API does not support this. Are there any plans on implementing this feature?
If not, would a pull request for this feature be accepted?
A similar feature exists in Mongo's API: positional update

@rhalff
Copy link
Owner

rhalff commented Apr 14, 2015

This is possible using dot.pick('foo.0.text', data);, I did not really see the additional benefit of adding bracket notation yet.

However it seems like some sort of check in parseKey could support that notation.

A pull request would be accepted, else I'll maybe add it later.

@rhalff
Copy link
Owner

rhalff commented Apr 15, 2015

I've added support for this notation in the new release (0.11.0)

@rhalff rhalff closed this as completed Apr 15, 2015
@foobar450
Copy link
Author

Awesome, thanks!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants