wankdanker / node-object-mapper

Copy properties from one object to another.
MIT License
276 stars 73 forks source link

Add a section with examples #67

Open BarryRufer opened 4 years ago

BarryRufer commented 4 years ago

Hello.

Need more examples.

"results": [{
  "books": [{
    "part": 1,
    "chapters": [
      {
        "chapter": 1
      }, {
        "chapter": 2
      }, {
        "chapter": 3
      }
    ]
  }]
}]

how to edit

"results": [{
  "books": [
    {
      "part": 1,
      "chapter": 1
    }, {
      "part": 1,
      "chapter": 2
    }, {
      "part": 1,
      "chapter": 3
    }
  ]
}]
switzer commented 4 years ago

Perhaps there is a way that we can implement a sandbox in jsfiddle or something similar?

bladimir-villarreal commented 3 years ago

Please, better examples of working with arrays and append items to an existing array, the example in the documentations it's very simple and i can't understand how use it

`{ "sourceArray[]": { "key": "destination[]+", "transform": (val) => mappingFunction(val) }, "otherSourceArray[]": { "key": "destination[]+", "transform": (val) => mappingFunction(val) } }

// Results in the destination array appending the source values { "destination": [ {/Results from the mapping function applied to sourceArray /}, {/Results from the mapping function applied to otherSourceArray /}, ] }`