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

Implement slice indexing when accessing a field #51

Open
ostafen opened this issue May 9, 2022 · 4 comments
Open

Implement slice indexing when accessing a field #51

ostafen opened this issue May 9, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ostafen
Copy link
Owner

ostafen commented May 9, 2022

Hi, all. Currently, clover allows to access nested document fields by the following syntax:

doc.Get("field1.field2.field3")

Now, suppose that field2 is a slice. It would be useful to support indexing elements by the following syntax:

doc.Get("field1.field2.4.field3") // here, we are trying to access the fifth element of "field2"
@ostafen ostafen added enhancement New feature or request good first issue Good for newcomers labels May 9, 2022
@ostafen ostafen self-assigned this May 9, 2022
@ostafen ostafen added this to the 1.2.0 milestone May 9, 2022
@ostafen ostafen assigned ostafen and unassigned ostafen May 9, 2022
@jinzhongjia
Copy link
Contributor

hi, bro.
i think you can release current version ,because the latest version not match the README

@ostafen ostafen removed this from the 1.2.0 milestone May 21, 2022
@ostafen
Copy link
Owner Author

ostafen commented May 21, 2022

v1.2.0 has been released :=)

@DaniloMarques1
Copy link
Contributor

Hello!
I would like to work on it.

Just a quick question: doc.Get("field1.field2.2") assuming field2 is a slice the correct result would be to return the second element of field2?

@ostafen
Copy link
Owner Author

ostafen commented Jun 4, 2022

Yes, that's right

DaniloMarques1 added a commit to DaniloMarques1/clover that referenced this issue Jun 5, 2022
- adding `books.json` to help on the slice testing;
- adding `lookupSliceField` that recursively dive inside a slice;
- adding test cases for the indexing structure.
DaniloMarques1 added a commit to DaniloMarques1/clover that referenced this issue Jun 5, 2022
- inverting condition.
DaniloMarques1 added a commit to DaniloMarques1/clover that referenced this issue Jun 5, 2022
- removing the `continue` from the for loop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants