diff --git a/docs/api/models.rst b/docs/api/models.rst index 4171acb6..11ec017c 100644 --- a/docs/api/models.rst +++ b/docs/api/models.rst @@ -7,6 +7,21 @@ backends and between the backends and the MPD frontend. All fields are optional and immutable. In other words, they can only be set through the class constructor during instance creation. +If you want to modify a model, use the +:meth:`~mopidy.models.ImmutableObject.copy` method. It accepts keyword +arguments for the parts of the model you want to change, and copies the rest of +the data from the model you call it on. Example:: + + >>> from mopidy.models import Track + >>> track1 = Track(name='Christmas Carol', length=171) + >>> track1 + Track(artists=[], length=171, name='Christmas Carol') + >>> track2 = track1.copy(length=37) + >>> track2 + Track(artists=[], length=37, name='Christmas Carol') + >>> track1 + Track(artists=[], length=171, name='Christmas Carol') + Data model relations ====================