Hey all!
Sorry in advance if the below is a bit messy in trying to explain what I want to do but thought I would put it out there.
I have a little question but unsure if there is an easier way in ColdBox/ORM to do this. I would like to merge two objects child arrays into the first object. For example see basic handler function below:
`
function basicMerge(event,rc,prc) {
prc.obj1 = userService.get(rc.id1);
prc.obj2 = userService.get(rc.id2);
}
`
Example return data for obj1:
- FirstName (Bob)
- LastName (Bobby)
- Hobbies (Array of hobbies)
— Cars
— Sports
— Movies
Example return data for obj2:
- FirstName (B o b)
- LastName (B o b b y)
- Hobbies (Array of hobbies)
— Music
— TV
— Photography
Of course the above is very simple, it’s just getting 2 objects based on different ID but I would like to merge/copy all the child arrays from obj2 into obj1 so the end result would look like this:
Example data for obj1 after merge:
- FirstName (Bob)
- LastName (Bobby)
- Hobbies (Array of hobbies)
— Cars
— Sports
— Movies
— Music
— TV
— Photography
Anyone know the easiest way to do this? Just to reconfirm the above is pretty simple and I know I could do some sort of ArrayAppend(), update ID of hobby and then save but I need to update ID relations on a lot of data spread over many models.
Cheers!