Currently toHash() assumes the column being indexed to be unique.
myModel.toHash("some_unique_key");
However, if the column being indexed is not actually unique you will have an undesired effect of the method overriding your data output
Take this data set for example.
| name |
gender |
| Bob |
M |
| Stan |
M |
| Rachel |
F |
| Julia |
F |
| Fred |
M |
Now when you run your data request
You will get back an object looking something like the following
{
"M": { "name": "Fred", "gender": "M" },
"F": { "name": "Julia", "gender": "F" }
}
This happens because the toHash method is overriding the index key in the return type after each iteration. I would propose that we make this consistent and instead return a grouped data set result.
{
"M": [
{ "name": "Bob", "gender": "M" }
{ "name": "Stan", "gender": "M" }
{ "name": "Fred", "gender": "M" }
],
"F": [
{ "name": "Rachel", "gender": "F" }
{ "name": "Julia", "gender": "F" }
]
}
Currently
toHash()assumes the column being indexed to be unique.However, if the column being indexed is not actually unique you will have an undesired effect of the method overriding your data output
Take this data set for example.
Now when you run your data request
You will get back an object looking something like the following
This happens because the
toHashmethod is overriding the index key in the return type after each iteration. I would propose that we make this consistent and instead return a grouped data set result.