[Voyage] Question about update of an object

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Voyage] Question about update of an object

CyrilFerlicot
Hi!

I have an application with Users that are voyage roots. Those Users can
have a object X that is also voyage roots.

I created a web application where a User can create an object X and save
it. But now I want to adapt the component to edit an existing X object.
What I have in mind is that I can copy the instance of X, let the user
change it and save the changes if the user click on "Edit" or discard
the changes if it click on "Cancel".

But I don't know how really works the update in Voyage. If I send "save"
to the copy of X, will it replace X inside the DB? Or should I create a
method "updateFrom:" in X to change all his variable to match the ones
from the parameter and then send "save" to the real X object?

Thanks

--
Cyril Ferlicot

http://www.synectique.eu

2 rue Jacques Prévert 01,
59650 Villeneuve d'ascq France


signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Voyage] Question about update of an object

NorbertHartl


> Am 22.10.2016 um 13:54 schrieb Cyril Ferlicot D. <[hidden email]>:
>
> Hi!
>
> I have an application with Users that are voyage roots. Those Users can
> have a object X that is also voyage roots.
>
> I created a web application where a User can create an object X and save
> it. But now I want to adapt the component to edit an existing X object.
> What I have in mind is that I can copy the instance of X, let the user
> change it and save the changes if the user click on "Edit" or discard
> the changes if it click on "Cancel".
>
> But I don't know how really works the update in Voyage. If I send "save"
> to the copy of X, will it replace X inside the DB? Or should I create a
> method "updateFrom:" in X to change all his variable to match the ones
> from the parameter and then send "save" to the real X object?
>
Voyage is about identity. If you copy an object then you have a second object and voyage will create a new one in the database. If you want update an object you need to update the object ;) and not a copy of it. If you have control of all the data updated in the UI then an approach like mementos might be appropriate. You can look at Magritte how it is done there. With immutable objects we'll have other options dealing with that.

Norbert

> Thanks
>
> --
> Cyril Ferlicot
>
> http://www.synectique.eu
>
> 2 rue Jacques Prévert 01,
> 59650 Villeneuve d'ascq France
>