# Move multiple objects

**URL:** <https://discourse.nodered.org/t/move-multiple-objects/34379>\
**Category:** General\
**Created:** [17 October 2020 00:22 UTC](https://discourse.nodered.org/t/move-multiple-objects/34379 "2020-10-17T00:22:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigfeetneedbigboots](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bigfeetneedbigboots/32/33216_2.png) [@bigfeetneedbigboots](https://discourse.nodered.org/u/bigfeetneedbigboots)\
**Post date:** [17 October 2020 00:22 UTC](https://discourse.nodered.org/t/move-multiple-objects/34379/1 "2020-10-17T00:22:40Z")

</div>

I'm using a node-red-contrib-simpletime node which adds a series of objects to the message based on what options I have ticked. For example, I am adding msg.mydate, msg.mymonth, msg.myday and so on. There are 10 in total.

After this step the message heads to a join node where I need all objects to be under the msg.payload object otherwise they get lost when joining using key/value object.

Right now I have a change node moving each object to the payload one by one and I update it each time I activate or deactivate an option. For example, I move msg.mydate to msg.payload.mydate and so on (10 times over).

Can you do a move (as a single operation compared to a set & delete) in a function node? Can you do a move based on a wildcard e.g. move msg.my\* to msg.payload.my\*?

Thanks for the assist.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 October 2020 03:35 UTC](https://discourse.nodered.org/t/move-multiple-objects/34379/2 "2020-10-17T03:35:05Z")

</div>

> [@bigfeetneedbigboots](#):
>
> Can you do a move (as a single operation compared to a set & delete) in a function node

Kinda. You could loop through the keys of the `msg` object & if the key starts with `my` then add that to the payload object.

Alternatively, would it not be enough to simply assign msg to the property `payload` of a new `msg` object? E.g.

```auto
return { payload : msg }

```

Alternatively, you could probably do it with a change node and JSONata (but I don't know how)

Lastly, you could request to the author for this feature (assuming it's not already a feature - I don't know, I don't use it)

---

<div class="post-metadata">

**Author:** ![bigfeetneedbigboots](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bigfeetneedbigboots/32/33216_2.png) [@bigfeetneedbigboots](https://discourse.nodered.org/u/bigfeetneedbigboots)\
**Post date:** [18 October 2020 01:26 UTC](https://discourse.nodered.org/t/move-multiple-objects/34379/3 "2020-10-18T01:26:34Z")

</div>

Thank you @Steve-Mcl...

> return { payload : msg }

... was exactly what I was looking for!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 November 2020 01:26 UTC](https://discourse.nodered.org/t/move-multiple-objects/34379/4 "2020-11-01T01:26:43Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
