Sumukha1496 / maskdata

maskdata is a node.js module to mask various kinds of data
MIT License
92 stars 7 forks source link

Supporting nested arrays #34

Closed dbani-dev closed 11 months ago

dbani-dev commented 12 months ago

I have been unable to mask nested arrays.

For example Data[*].items[*].id does not mask id in every items array:

{
"Data": [
    {
      "id": "1111",
      "name": "Test",
      "items": [
        {
          "id": "1111",
          "name": "11115",
        },
        {
          "id": "1111",
          "name": "11111",
        }
      ],

    },
     {
      "id": "1111",
      "name": "Test",
      "items": [
        {
          "id": "1111",
          "name": "11115",
        },
        {
          "id": "1111",
          "name": "11111",
        }
      ],
    }
  ]
}

Items array is completely masked. Unless there is a workaround?

Also is there a way for apply a mask to ALL related fields without having to traverse? E.g. fields: ['name']

Will update ALL name fields:

{
  "name": "****",
  "items": {
     "name": "****"
   }
}
Sumukha1496 commented 12 months ago

Hi @davidbani , for the first issue, currently it supports only 1 . So 1 iteration is needed. Iterate through data and for each data, you can mask items[].id

Currently 2nd feature is not supported. But both features seems really cool and good to have. I will work on it and push these changes in the next version. I will keep you updated. Thanks for raising the issue.

Sumukha1496 commented 11 months ago

Hi @davidbani , please check this: https://www.npmjs.com/package/maskdata?activeTab=readme#mask-multiple-fields and let me know if there are any issues

Sumukha1496 commented 10 months ago

@davidbani , use version 1.2.6 to have the mentioned feature.