You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From what I've seen in the Basic CRUD section of the docs, it seems like we need to manually Set every field that needs to be updated before passing to the update function.
Is there any method to pass a reference and expect it to update all or most of the fields?
The text was updated successfully, but these errors were encountered:
Hey @VaZark, I'm not sure what you mean by "pass a reference and expect it to update all or most of the fields". Could you show me a demo for it? Thanks!
let task:Option<task::Model> = Task::find_by_id(id).one(conn).await.expect("Error fetching");// Parsed from input JSON<task::Model>letmut payload: task::ActiveModel = payload.into();
payload.id = Set(task.id);// When I run the following, I expected it to update all the fields// However since only the id field is Set, only that is updated (makes sense ofc)let updated_task = payload.update(conn).await;//It would cleaner if I could do something likelet updated_task = payload.updateAllFields(conn).await;
From what I've seen in the Basic CRUD section of the docs, it seems like we need to manually
Set
every field that needs to be updated before passing to theupdate
function.Is there any method to pass a reference and expect it to update all or most of the fields?
The text was updated successfully, but these errors were encountered: