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

Provide a Map implementation #24

Open
nicklayb opened this issue Sep 9, 2024 · 0 comments
Open

Provide a Map implementation #24

nicklayb opened this issue Sep 9, 2024 · 0 comments
Labels
enhancement New feature or request implementation Concerns a implementation (like Ecto)

Comments

@nicklayb
Copy link
Owner

nicklayb commented Sep 9, 2024

Provide an implementation that allows crawling a Map using the predicates. Example:

players = [
  %{"name" => "Neil Peart", "jobs" => ["song_writing", "drums"]},
  %{"name" => "Geddy Lee", "jobs" => ["bass", "keyboard"]},
  %{"name" => "Alex Lifeson", "jobs" => ["guitar"]}
]

map %{players: players}

And use query like

get players where jobs in ["bass", "drum"]
# would return Neil Peart and Geddy Lee

Considrations

  • Should be insensitive to the key types, should work on atom and string maps and even mixed up in the nesting (not mixed in the same map but mixed nested, example: %{name: "Neil Peart", "jobs" => []} wouldn't be accepted, but %{band: "Rush", members: [%{"name" => "Neil Peart"}]} would)
  • Variants should not be hardcoded and user implemented instead. So someone can have get players where name:insensitive = "geddy lee".
  • Paths should be used for keys that cannot be identifier (keys with space, for instance), like: get players where country["city name"] for a map that looks like %{"country" => %{"city name" => city}}.
  • The returned value of the impletation should probably by a lambda function that accepts a map or call it directly, to be determined. But it would be best to avoid crawling the whole map so maybe giving out another kind of structure that can directly use get_in on the map.
@nicklayb nicklayb added implementation Concerns a implementation (like Ecto) enhancement New feature or request labels Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request implementation Concerns a implementation (like Ecto)
Projects
None yet
Development

No branches or pull requests

1 participant