To merge the data of two instances of the same type, the attributes defined in `DatabaseObject.COLLECTION_STRING_ATTRIBUTES` and `SIMPLE_STRING_ATTRIBUTES` are used.
Then you can for example append a new Object. The difference to a normal list is, that if you have two different objects that both represent the same data, it doesn't get added, but all data gets [merged](#databaseobjectmerge) into the existing Object instead.
For example, you have two different Artist-Objects, where both have one source in common. The one Artist-Object already is in the Collection. The other artist object is passed in the append command.
In this case it doesn't simply add the artist object to the collection, but modifies the already existing Artist-Object, adding all attributes the new artist object has, and then discards the other object.
If you want to append for example a Song to an Album, you obviously need to check beforehand if the Song already exists in the Album, and if so, you need to merge their data in one Song object, to not loose any Information.
_map("""In case a new source or something simmilar
has been addet, it maps the existing object again.
""")
_merge --> _map
end
subgraph add["Adding"]
__map("""map the values from <code>music_object.indexing_values</code>
to <code>Collection._attribute_to_object_map</code> by writing
those values in the map as keys, and the class I wanna add as values.
""")
_add("""add the new music object to <code>_data</code>""")
__map --> _add
end
exist-->|"if it doesn't exist"|add --> return
exist-->|"if already exists"|merge --> return
```
This is Implemented in [music_kraken.objects.Collection.append()](documentation/objects.md#collection). The merging which is mentioned in the flowchart is explained in the documentation of [DatabaseObject.merge()](documentation/objects.md#databaseobjectmerge).
The <u>indexing values</u> are defined in the superclass [DatabaseObject](documentation/objects.md#databaseobject) and get implemented for each Object seperately. I will just give as example its implementation for the `Song` class:
This object inherits from [DatabaseObject](#databaseobject) and implements all its interfaces.
It has handful attributes, where half of em are self-explanatory, like `title` or `genre`. The ones like `isrc` are only relevant to you, if you know what it is, so I won't elaborate on it.
Interesting is the `date`. It uses a custom class. More on that [here](#music_krakenid3timestamp).
## ID3Timestamp
For multiple Reasons I don't use the default `datetime.datetime` class.
The most important reason is, that you need to pass in at least year, month and day. For every other values there are default values, that are indistinguishable from values that are directly passed in. But I need optional values. The ID3 standart allows default values. Additionally `datetime.datetime` is immutable, thus I can't inherint all the methods. Sorry.
Anyway you can create those custom objects easily.
```python
from music_kraken import ID3Timestamp
# returns an instance of ID3Timestamp with the current time
ID3Timestamp.now()
# returns an instance of ID3Timestamp with the given values