leblad
leblad copied to clipboard
Feature request: Extend wilayaProjection to project nested fields
Related to wilayaProjection:
The goal if this helper function is to return only the Wilaya objects properties that a user wants (Otherwise they will receive an element like this big & ugly 😄 ).
For now we can use this feature to only return only wilaya fields we want (example, and it will be great if we can project dairats (a Wilaya property containing an array of objects).
So when we call:
projectWilaya(someWilayaObject, ['name', 'dairats.name']);
You should only return the wilaya name and only names of its dairats
.
We'd prefer a simple and minimalist solution, but if needed you can use any library you like. If you need some inspiration you can check projects like jq. Or just keep it simple, split by .
and then add a magical recursive function to project daira
object
@InternetRamen can you take it?
@Fcmam5 I think I can take it.
@Fcmam5 In your example,
projectWilaya(someWilayaObject, ['name', 'dairats.name']);
, would it return ['name', 'theNameOfDairats']
or something more like ['name', {name: "theNameOfDairats"}}
I mean that if we want only the wilaya name
, and its dairats' names
we call it with projectWilaya(someWilayaObject, ['name', 'dairats.name']);
Example: For Adrar
wilaya object, I'd expect it to return something like:
[
{
"name": "Adrar",
"dairats": [
{
"name": "ADRAR"
},
{
"name": "CHAROUINE"
},
{
"name": "REGGANE"
},
...
]
}
]
#28
@Fcmam5 mattricule
is mandatory or it was just a typo?
@Fcmam5
mattricule
is mandatory or it was just a typo?
Sorry, it was a typo 😅