leblad icon indicating copy to clipboard operation
leblad copied to clipboard

Feature request: Extend wilayaProjection to project nested fields

Open Fcmam5 opened this issue 4 years ago • 7 comments

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

Fcmam5 avatar Sep 30 '20 23:09 Fcmam5

@InternetRamen can you take it?

Fcmam5 avatar Sep 30 '20 23:09 Fcmam5

@Fcmam5 I think I can take it.

InternetRamen avatar Sep 30 '20 23:09 InternetRamen

@Fcmam5 In your example, projectWilaya(someWilayaObject, ['name', 'dairats.name']);, would it return ['name', 'theNameOfDairats'] or something more like ['name', {name: "theNameOfDairats"}}

InternetRamen avatar Oct 01 '20 01:10 InternetRamen

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"
      },
      ...
    ]
  }
]     

Fcmam5 avatar Oct 01 '20 09:10 Fcmam5

#28

InternetRamen avatar Oct 01 '20 14:10 InternetRamen

@Fcmam5 mattricule is mandatory or it was just a typo?

AMTazi avatar Dec 04 '20 18:12 AMTazi

@Fcmam5 mattricule is mandatory or it was just a typo?

Sorry, it was a typo 😅

Fcmam5 avatar Dec 05 '20 10:12 Fcmam5