Update multiple instances #1624
Answered
by
thetutlage
rodolphonetto
asked this question in
Help
-
Hey guys, when I need to update a lot instances I'm using a loop but I dont think that this is the best way, look at the code below, when I use the .toJSON() to iterate the itens loses the .merge so I need to find it again, there is a better way for doing that?
|
Beta Was this translation helpful? Give feedback.
Answered by
thetutlage
Sep 20, 2020
Replies: 1 comment 1 reply
-
Why you are using for (const approver of approversToCleanUnity.rows) {
approver.merge({ unity_id: null })
await approver.save()
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
thetutlage
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why you are using
toJSON
? The main purpose of toJSON is to serialize the model to a plain Javascript object. Simply loop as follows: